lib/compose.js
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.compose = compose;
/**
* Performs right-to-left function composition.
*
* @since v0.1.0
* @param {any} ...args
* @return {Function}
* @example
* const f = compose(a => a + 1, a => -a, Math.pow)
* f(3, 4) //=> -80
*/
function compose() {
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return args.reduce(function (result, fn) {
return function () {
return result(fn.apply(undefined, arguments));
};
});
}