-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathcurryArgs4.js
65 lines (59 loc) · 1.57 KB
/
curryArgs4.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
const __ = require('./placeholder')
// argument resolver for curryArgs4
const curryArgs4ResolveArgs0 = (
baseFunc, arg1, arg2, arg3,
) => function args0Resolver(...args) {
return baseFunc(args, arg1, arg2, arg3)
}
// argument resolver for curryArgs4
const curryArgs4ResolveArgs1 = (
baseFunc, arg0, arg2, arg3,
) => function args1Resolver(...args) {
return baseFunc(arg0, args, arg2, arg3)
}
// argument resolver for curryArgs4
const curryArgs4ResolveArgs2 = (
baseFunc, arg0, arg1, arg3,
) => function args2Resolver(...args) {
return baseFunc(arg0, arg1, args, arg3)
}
// argument resolver for curryArgs4
const curryArgs4ResolveArgs3 = (
baseFunc, arg0, arg1, arg2,
) => function args3Resolver(...args) {
return baseFunc(arg0, arg1, arg2, args)
}
/**
* @name curryArgs4
*
* @synopsis
* ```coffeescript [specscript]
* __ = Symbol('placeholder')
*
* curryArgs4(
* baseFunc function,
* arg0 __|any,
* arg1 __|any,
* arg2 __|any
* arg3 __|any,
* ) -> function
* ```
*
* @description
* Curry arguments for a 4-ary function. Arguments are supplied in placeholder position as an array.
*
* Note: at least one argument must be the placeholder
*/
const curryArgs4 = function (baseFunc, arg0, arg1, arg2, arg3) {
if (arg0 == __) {
return curryArgs4ResolveArgs0(baseFunc, arg1, arg2, arg3)
}
if (arg1 == __) {
return curryArgs4ResolveArgs1(baseFunc, arg0, arg2, arg3)
}
if (arg2 == __) {
return curryArgs4ResolveArgs2(baseFunc, arg0, arg1, arg3)
}
return curryArgs4ResolveArgs3(baseFunc, arg0, arg1, arg2)
}
module.exports = curryArgs4