UNPKG
rsite-funjs
Version:
latest (1.0.20)
1.0.20
1.0.19
1.0.18
1.0.17
1.0.16
1.0.15
1.0.13
functional javascript
github.com/neu-rah/funjs
neu-rah/funjs
rsite-funjs
/
src
/
curry.js
13 lines
(9 loc)
•
306 B
JavaScript
View Raw
1
2
3
4
5
6
7
8
9
10
11
12
13
"use strict"
;
// based from https://javascript.info/currying-partials
const
curry
=f=>
function
curried
(
...aa
) {
const
a=aa.
length
?
aa
:[
undefined
]
return
a.
length
>= f.
length
? f.
apply
(
this
, a):
function
(
...b
) {
return
curried.
apply
(
this
, a.
concat
(b.
length
?
b
:
undefined
));} };
exports
.
curry
=curry