es5实现
const compose = function (func) {
let len = func.length;
let count = len - 1;
let result;
return function f1(...arg1) {
result = func[count].apply(this, arg1);
if (count <= 0) {
count = len - 1;
return result;
}
count--;
return f1.call(null, result);
};
};
复制代码
redux实现
const reduxCompose = (func) => {
const len = func.length;
if (len === 0) {
return (arg) => arg;
}
if (len === 1) {
return func[0];
}
return func.reduce((a, b) => (...args) => a(b(...args)));
};
复制代码
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END























![[桜井宁宁]COS和泉纱雾超可爱写真福利集-一一网](https://www.proyy.com/skycj/data/images/2020-12-13/4d3cf227a85d7e79f5d6b4efb6bde3e8.jpg)

![[桜井宁宁] 爆乳奶牛少女cos写真-一一网](https://www.proyy.com/skycj/data/images/2020-12-13/d40483e126fcf567894e89c65eaca655.jpg)