hoff
Version:
A collection of higher order functions you may find useful
24 lines (21 loc) • 757 B
JavaScript
;
// function currying -
// Will keep returning functions until all arguments
// are given, then will return the value
// of the executed function.
Object.defineProperty(exports, '__esModule', {
value: true
});
var curry = function curry(f) {
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}
return args.length < f.length ? function () {
for (var _len2 = arguments.length, more = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
more[_key2] = arguments[_key2];
}
return curry.apply(undefined, [f].concat(args, more));
} : f.apply(undefined, args);
};
exports['default'] = curry;
module.exports = exports['default'];