-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcurry.js
30 lines (30 loc) · 982 Bytes
/
curry.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define([], function () {
return (root.returnExportsGlobal = factory());
});
} else if (typeof module === 'object' && module.exports) {
// Node. Does not work with strict CommonJS, but
// only CommonJS-like environments that support module.exports,
// like Node.
module.exports = factory();
} else {
// Browser globals
root.returnExportsGlobal = factory();
}
}(this, function () {
return function (fn, ...a) {
let numArguments = fn.length;
let args = [];
let currier = function (...newArgs) {
args = args.concat(newArgs);
if (args.length === numArguments) {
return fn(...args);
} else {
return currier;
}
};
return currier(...a);
}
}));