curry

说明

函数柯里化

源码

用法

curry.test.ts
1
import { curry } from "../../utility/function/curry";
2
3
describe('curry() tests...', () => {
4
test('method curry should works normally', () => {
5
const received = function (a: number, b: number, c: number, d: number) {
6
return a + b + c + d;
7
}
8
9
const curriedFunc = curry(received);
10
11
expect(curriedFunc(1, 2, 3)(4)).toBe(10);
12
expect(curriedFunc(100)(200)(300)(400)).toBe(1000);
13
expect(curriedFunc(23)(34, 45)(56)).toBe(158);
14
});
15
});
Copied!
最近更新 1yr ago
复制链接