about summary refs log tree commit diff stats
path: root/js
diff options
context:
space:
mode:
authorelioat <hi@eli.li>2023-07-18 14:02:29 -0400
committerelioat <hi@eli.li>2023-07-18 14:02:29 -0400
commitdd55dd0bc450400e676a3b1e874921bf05242f17 (patch)
tree230299c6ab3a5a621b9efda9826c79599ac4e82d /js
parent573b63ff95c85c932c55e0c8888bffdc6704ed1a (diff)
downloadtour-dd55dd0bc450400e676a3b1e874921bf05242f17.tar.gz
*
Diffstat (limited to 'js')
-rw-r--r--js/curry.js11
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);
+  };
+}