UNPKG

entrust

Version:

delegatee-last structure for curried functions

94 lines (77 loc) 2.66 kB
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var katsuCurry = require('katsu-curry'); var entrust0 = function (fn, x) { return x[fn](); }; var e0 = katsuCurry.curry(entrust0); var entrust1 = function (fn, a, x) { return x[fn](a); }; var e1 = katsuCurry.curry(entrust1); var entrust2 = function (fn, a, b, x) { return x[fn](a, b); }; var e2 = katsuCurry.curry(entrust2); var entrust3 = function (fn, a, b, c, x) { return x[fn](a, b, c); }; var e3 = katsuCurry.curry(entrust3); var entrust4 = function (fn, a, b, c, d, x) { return x[fn](a, b, c, d); }; var e4 = katsuCurry.curry(entrust4); var entrust5 = function (fn, a, b, c, d, e, x) { return x[fn](a, b, c, d, e); }; var e5 = katsuCurry.curry(entrust5); var entrust6 = function (fn, a, b, c, d, e, f, x) { return x[fn](a, b, c, d, e, f); }; var e6 = katsuCurry.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 = katsuCurry.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 = katsuCurry.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 = katsuCurry.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 = katsuCurry.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 = katsuCurry.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 = katsuCurry.curry( entrustD ); var custom = function (curry) { 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(raw[k]), obj )); }).reduce(function (x, y) { return Object.assign({}, x, y); }, {}) }; exports.e0 = e0; exports.e1 = e1; exports.e2 = e2; exports.e3 = e3; exports.e4 = e4; exports.e5 = e5; exports.e6 = e6; exports.e7 = e7; exports.e8 = e8; exports.e9 = e9; exports.e10 = e10; exports.eN = eN; exports.eD = eD; exports.custom = custom;