You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

14 lines
442 B

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.compose = void 0;
/**
* 将多个单个参数的函数合成为一个函数,执行顺序为从右到左
* @param fn 第一个函数
* @param rest 剩余函数
* @returns 复合后的函数
*/
function compose(fn, ...rest) {
return rest.reduce((pre, cur) => (x) => pre(cur(x)), fn);
}
exports.compose = compose;
//# sourceMappingURL=compose.js.map