diff options
author | elioat <hi@eli.li> | 2023-07-18 14:02:29 -0400 |
---|---|---|
committer | elioat <hi@eli.li> | 2023-07-18 14:02:29 -0400 |
commit | dd55dd0bc450400e676a3b1e874921bf05242f17 (patch) | |
tree | 230299c6ab3a5a621b9efda9826c79599ac4e82d /js | |
parent | 573b63ff95c85c932c55e0c8888bffdc6704ed1a (diff) | |
download | tour-dd55dd0bc450400e676a3b1e874921bf05242f17.tar.gz |
*
Diffstat (limited to 'js')
-rw-r--r-- | js/curry.js | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/js/curry.js b/js/curry.js new file mode 100644 index 0000000..1d2266c --- /dev/null +++ b/js/curry.js @@ -0,0 +1,11 @@ +function curry(fn) { + const arity = fn.length; + + return function $curry(...args) { + if (args.length < arity) { + return $curry.bind(null, ...args); + } + + return fn.call(null, ...args); + }; +} |