source: node_modules/es-toolkit/dist/function/curry.mjs@ a762898

Last change on this file since a762898 was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago

Added visualizations

  • Property mode set to 100644
File size: 486 bytes
Line 
1function curry(func) {
2 if (func.length === 0 || func.length === 1) {
3 return func;
4 }
5 return function (arg) {
6 return makeCurry(func, func.length, [arg]);
7 };
8}
9function makeCurry(origin, argsLength, args) {
10 if (args.length === argsLength) {
11 return origin(...args);
12 }
13 else {
14 const next = function (arg) {
15 return makeCurry(origin, argsLength, [...args, arg]);
16 };
17 return next;
18 }
19}
20
21export { curry };
Note: See TracBrowser for help on using the repository browser.