tsoid
Version:
Typed functional library to deal with async operations.
15 lines (14 loc) • 432 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const id_1 = require("./id");
/**
* Compose two or more function into one function.
*
* @param {function} fnl
* @param {function[]} fns
*/
function compose(fnl, ...fns) {
const composed = fns.reduceRight((composedFn, fn) => (value) => fn(composedFn(value)), id_1.default);
return (input) => fnl(composed(input));
}
exports.default = compose;