1 |
|
2 | function createFn(fn, args, totalArity){
|
3 | const curried = (...partialArgs) => {
|
4 | return processInvocation.call(this, fn, args.concat(partialArgs), totalArity);
|
5 | };
|
6 | curried.curried = true;
|
7 | return curried;
|
8 | }
|
9 |
|
10 | function processInvocation(fn, args, totalArity){
|
11 | if (args.length === totalArity){
|
12 | return fn.apply(this, args);
|
13 | }else{
|
14 | return createFn(fn, args, totalArity);
|
15 | }
|
16 | }
|
17 |
|
18 | export default (
|
19 | count: number,
|
20 | fn: Function,
|
21 | ): Function => {
|
22 | return createFn(fn, [], count);
|
23 | };
|