deno.land / x / rambda@v9.1.1 / source / curry.spec.js

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import { curry } from './curry.js'
test('happy', () => { const addFourNumbers = ( a, b, c, d ) => a + b + c + d const curriedAddFourNumbers = curry(addFourNumbers) const f = curriedAddFourNumbers(1, 2) const g = f(3)
expect(g(4)).toBe(10)})
test('when called with more arguments', () => { const add = curry((n, n2) => n + n2)
expect(add( 1, 2, 3 )).toBe(3)})
test('when called with zero arguments', () => { const sub = curry((a, b) => a - b) const s0 = sub()
expect(s0(5, 2)).toBe(3)})
test('when called via multiple curry stages', () => { const join = curry(( a, b, c, d ) => [ a, b, c, d ].join('-'))
const stage1 = join('A') const stage2 = stage1('B', 'C')
expect(stage2('D')).toBe('A-B-C-D')})
rambda

Version Info

Tagged at
2 months ago