everyutil
Version:
A comprehensive library of lightweight, reusable utility functions for JavaScript and TypeScript, designed to streamline common programming tasks such as string manipulation, array processing, date handling, and more.
12 lines (11 loc) • 352 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ifElse = void 0;
/**
* Creates a function that runs one of two paths based on a predicate.
* @author @dailker
*/
function ifElse(predicate, ifFn, elseFn) {
return (input) => predicate(input) ? ifFn(input) : elseFn(input);
}
exports.ifElse = ifElse;