1
|
"use strict";const b={curry:function(fn){const curried=(...args)=>{if(args.length>=fn.length)return fn(...args);else return(...rest)=>curried(...args,...rest)};return curried},pipe:(...fns)=>value=>fns.reduce((acc,fn)=>fn(acc),value),compose:(...fns)=>(...args)=>fns.reduceRight((res,fn)=>fn(...[].concat(res)),args),identity:x=>x,match:function(){return this.curry((what,s)=>s.match(what))},replace:function(){return this.curry((what,replacement,s)=>s.replace(what,replacement))},filter:function(){return this.curry((f,xs)=>xs.filter(f))},map:function(){return this.curry((f,xs)=>xs.map(f))},deepMap:function(){return this.curry(function deepMap(f,xs){return Array.isArray(xs)?xs.map(x=>deepMap(f,x)):f(xs)})}};export default b;
|