UNPKG

442 BJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.compose = void 0;
4/**
5 * 将多个单个参数的函数合成为一个函数,执行顺序为从右到左
6 * @param fn 第一个函数
7 * @param rest 剩余函数
8 * @returns 复合后的函数
9 */
10function compose(fn, ...rest) {
11 return rest.reduce((pre, cur) => (x) => pre(cur(x)), fn);
12}
13exports.compose = compose;
14//# sourceMappingURL=compose.js.map
\No newline at end of file