20 lines
546 B
JavaScript
20 lines
546 B
JavaScript
function curry(fn) {
|
|
return function curried() {
|
|
var _this = this;
|
|
|
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
args[_key] = arguments[_key];
|
|
}
|
|
|
|
return args.length >= fn.length ? fn.apply(this, args) : function () {
|
|
for (var _len2 = arguments.length, nextArgs = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
nextArgs[_key2] = arguments[_key2];
|
|
}
|
|
|
|
return curried.apply(_this, [].concat(args, nextArgs));
|
|
};
|
|
};
|
|
}
|
|
|
|
export default curry;
|