d-utils
Version:
d-utils
26 lines (25 loc) • 931 B
JavaScript
/**
* d-utils version: 4.0.3
* by ifmiss
*/
;var r=require("./_tslib-282d34cf.js");
/**
* @description 函数柯里化工具
* @param { Function } fn 方法
* @param { Any } agrs 参数,可选
* @example
* const addCur = function (a, b, c) {
* console.log('a + b + c', a + b + c)
* }
* const reduceCur = function (a, b, c) {
* console.log('a - b - c', a - b - c)
* }
* const add = curry(addCur, 2)
* s(1)(2) // a + b + c 6
* s(1, 3) // a + b + c 6
*
* const reduce = curry(reduceCur)
* const reduce1 = curry(reduceCur)
* reduce(1)(2)(3) // a - b - c -1
* reduce1(1, 2, 3) // a - b - c -3
*/module.exports=function e(a){for(var t=[],l=1;l<arguments.length;l++)t[l-1]=arguments[l];var p=this,s=Array.from(arguments).slice(1),n=a.length;return function(){var t=Array.from(arguments);return s.push.apply(s,r.__spread(t)),s.length<n?e.call.apply(e,r.__spread([p,a],s)):a.apply(p,s)}};