You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
750 B
24 lines
750 B
3 years ago
|
"use strict";
|
||
|
|
||
|
exports.__esModule = true;
|
||
|
exports["default"] = curry;
|
||
|
|
||
|
// Type definitions taken from https://github.com/gcanti/flow-static-land/blob/master/src/Fun.js
|
||
|
// eslint-disable-next-line no-unused-vars
|
||
|
// eslint-disable-next-line no-unused-vars
|
||
|
// eslint-disable-next-line no-redeclare
|
||
|
function curried(f, length, acc) {
|
||
|
return function fn() {
|
||
|
// eslint-disable-next-line prefer-rest-params
|
||
|
var combined = acc.concat(Array.prototype.slice.call(arguments));
|
||
|
return combined.length >= length ? f.apply(this, combined) : curried(f, length, combined);
|
||
|
};
|
||
|
} // eslint-disable-next-line no-redeclare
|
||
|
|
||
|
|
||
|
function curry(f) {
|
||
|
// eslint-disable-line no-redeclare
|
||
|
return curried(f, f.length, []);
|
||
|
}
|
||
|
|
||
|
module.exports = exports.default;
|