1 | var _arity =
|
2 |
|
3 | require("./_arity");
|
4 |
|
5 | var _isPlaceholder =
|
6 |
|
7 | require("./_isPlaceholder");
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 | function _curryN(length, received, fn) {
|
21 | return function () {
|
22 | var combined = [];
|
23 | var argsIdx = 0;
|
24 | var left = length;
|
25 | var combinedIdx = 0;
|
26 |
|
27 | while (combinedIdx < received.length || argsIdx < arguments.length) {
|
28 | var result;
|
29 |
|
30 | if (combinedIdx < received.length && (!_isPlaceholder(received[combinedIdx]) || argsIdx >= arguments.length)) {
|
31 | result = received[combinedIdx];
|
32 | } else {
|
33 | result = arguments[argsIdx];
|
34 | argsIdx += 1;
|
35 | }
|
36 |
|
37 | combined[combinedIdx] = result;
|
38 |
|
39 | if (!_isPlaceholder(result)) {
|
40 | left -= 1;
|
41 | }
|
42 |
|
43 | combinedIdx += 1;
|
44 | }
|
45 |
|
46 | return left <= 0 ? fn.apply(this, combined) : _arity(left, _curryN(length, combined, fn));
|
47 | };
|
48 | }
|
49 |
|
50 | module.exports = _curryN; |
\ | No newline at end of file |