entrust
Version:
delegatee-last structure for curried functions
77 lines (62 loc) • 2.26 kB
JavaScript
import { curry } from 'katsu-curry';
var entrust0 = function (fn, x) { return x[fn](); };
var e0 = curry(entrust0);
var entrust1 = function (fn, a, x) { return x[fn](a); };
var e1 = curry(entrust1);
var entrust2 = function (fn, a, b, x) { return x[fn](a, b); };
var e2 = curry(entrust2);
var entrust3 = function (fn, a, b, c, x) { return x[fn](a, b, c); };
var e3 = curry(entrust3);
var entrust4 = function (fn, a, b, c, d, x) { return x[fn](a, b, c, d); };
var e4 = curry(entrust4);
var entrust5 = function (fn, a, b, c, d, e, x) { return x[fn](a, b, c, d, e); };
var e5 = curry(entrust5);
var entrust6 = function (fn, a, b, c, d, e, f, x) { return x[fn](a, b, c, d, e, f); };
var e6 = curry(entrust6);
var entrust7 = function (fn, a, b, c, d, e, f, g, x) { return x[fn](a, b, c, d, e, f, g); };
var e7 = curry(entrust7);
var entrust8 = function (fn, a, b, c, d, e, f, g, h, x) { return x[fn](a, b, c, d, e, f, g, h); };
var e8 = curry(entrust8);
var entrust9 = function (fn, a, b, c, d, e, f, g, h, i, x) { return x[fn](a, b, c, d, e, f, g, h, i); };
var e9 = curry(entrust9);
var entrust10 = function (fn, a, b, c, d, e, f, g, h, i, j, x) { return x[fn](
a, b, c, d, e, f, g, h, i, j
); };
var e10 = curry(entrust10);
var entrustN = function (n, method, args, delegatee) {
var entrustees = [e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10];
var params = [method ].concat( args, [delegatee]);
return entrustees[n].apply(null, params)
};
var eN = curry(entrustN);
function entrustD(n, m, a, d) {
if (n !== a.length) {
throw new Error((m + " expects total args (" + (a.length) + ") to equal the given arity (" + n + ")"))
}
return entrustN(n, m, a, d)
}
var eD = curry(
entrustD
);
var custom = function (curry$$1) {
var raw = {
e0: entrust0,
e1: entrust1,
e2: entrust2,
e3: entrust3,
e4: entrust4,
e5: entrust5,
e6: entrust6,
e7: entrust7,
e8: entrust8,
e9: entrust9,
e10: entrust10,
eD: entrustD,
eN: entrustN
};
return Object.keys(raw).map(function (k) {
var obj;
return (( obj = {}, obj[k] = curry$$1(raw[k]), obj ));
}).reduce(function (x, y) { return Object.assign({}, x, y); }, {})
};
export { e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, eN, eD, custom };