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