more composable magic

This commit is contained in:
alex
2023-01-11 22:27:00 +00:00
parent d5ab1a3471
commit 6dda6bac66
+10 -1
View File
@@ -147,7 +147,16 @@ export function curry(func, overload, arity = func.length) {
return func.apply(this, args);
} else {
const partial = function (...args2) {
return curried.apply(this, args.concat(args2));
const result = curried.apply(this, args.concat(args2));
if (args.length == arity - 1) {
// The penultimate arg.. so add some composition magic
// TODO - To make this useful, we also need to add stub functions for every pattern method to
// do the actual composing
result.__compose = function (pat) {
return result(pat);
};
}
return result;
};
if (overload) {
overload(partial, args);