-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkatsu-curry.mjs
1 lines (1 loc) · 3.24 KB
/
katsu-curry.mjs
1
var PLACEHOLDER='\uD83C\uDF5B',$=PLACEHOLDER;var bindInternal3=function(d,e){return function(f,a,b){return d.call(e,f,a,b)}};var some$1=function(a,b,c){var d,e=a.length,f=c===void 0?b:bindInternal3(b,c);for(d=0;d<e;d++)if(f(a[d],d,a))return!0;return!1},curry=function(a){var b=function(a){return a===PLACEHOLDER};return function c(){for(var d=arguments,e=arguments.length,f=Array(e),g=0;g<e;++g)f[g]=d[g];var h=some$1(f,b)?function(a){for(var c=a.length;!b(a[c]);)c--;return c}(f):f.length;return h>=a.length?a.apply(this,f):function(){for(var a=arguments,d=arguments.length,e=Array(d),g=0;g<d;++g)e[g]=a[g];return c.apply(this,f.map(function(a){return b(a)&&e[0]?e.shift():a}).concat(e))}}},innerpipe=function(b){return function(c){for(var d=b[0],e=b.slice(1),f=d(c),g=0;g<e.length;g++)f=e[g](f);return f}};function pipe(){for(var a=arguments,b=arguments.length,c=Array(b),d=0;d<b;++d)c[d]=a[d];return innerpipe(c)}var prop=curry(function(a,b){return b&&a&&b[a]}),_assign=Object.assign,_keys=Object.keys,keys=_keys,assign=_assign,merge=curry(function(c,a){return assign({},c,a)}),propLength=prop('length'),objectLength=pipe(keys,propLength),length=function(a){return'object'==typeof a?objectLength(a):propLength(a)},delegatee=curry(function(a,b,c){return c[a](b)}),filter=delegatee('filter'),flipIncludes=curry(function(a,b){return a.includes(b)}),matchingKeys=curry(function(a,b){return filter(flipIncludes(a),keys(b))}),matchingKeyCount=curry(function(a,b){return pipe(matchingKeys(a),length)(b)}),expectKArgs=function(a,b){return matchingKeyCount(a,b)>=Object.keys(a).length},curryObjectK=curry(function(a,b){return function c(d){return Object.keys(d).filter(function(b){return a.includes(b)}).length===a.length?b(d):function(a){return c(Object.assign({},d,a))}}});function curryObjectN(a,b){return function c(d){return d&&Object.keys(d).length>=a?b(d):function(a){return c(Object.assign({},d,a))}}}function curryObjectKN(a,b){var c=a.k,d=a.n;return function a(e){return expectKArgs(c,e)||Object.keys(e).length>=d?b(e):function(b){return a(Object.assign({},e,b))}}}function compose(){for(var a=arguments,b=arguments.length,c=Array(b),d=b-1;-1<d;--d)c[d]=a[d];return innerpipe(c)}var curryify=function(a){if('function'!=typeof a)throw new TypeError('Expected to be given a function to test placeholders!');return function(b){if('function'!=typeof b)throw new TypeError('Expected to be given a function to curry!');return function c(){for(var d=arguments,e=arguments.length,f=Array(e),g=0;g<e;++g)f[g]=d[g];var h=some$1(f,a)?function(b){for(var c=b.length;!a(b[c]);)c--;return c}(f):f.length;return h>=b.length?b.apply(this,f):function(){for(var b=arguments,d=arguments.length,e=Array(d),g=0;g<d;++g)e[g]=b[g];return c.apply(this,f.map(function(b){return a(b)&&e[0]?e.shift():b}).concat(e))}}}},version='0.7.5',K=function(a){return function(){return a}},I=function(a){return a},remapParameters=function(a,b){var c=Array.from(b);return c.length?c.map(function(b,d){return a.includes(d)?c[a[d]]:b}):c},remapArray=curry(remapParameters),remapFunction=function(a,b){var c=remapArray(a),d=curry(b);return function(){var a=c(Array.from(arguments));return d.apply(null,a)}},remap=curry(remapFunction);export{$,PLACEHOLDER,curry,curryObjectK,curryObjectN,curryObjectKN,pipe,compose,curryify,version,K,I,remap,remapArray};