Skip to main content
Module

x/rambda/curry.spec.js

Faster and smaller alternative to Ramda
Go to Latest
File
import { curry } from './curry'
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)).toEqual(10)})
test('when called with more arguments', () => { const add = curry((n, n2) => n + n2)
expect(add( 1, 2, 3 )).toEqual(3)})
test('when called with zero arguments', () => { const sub = curry((a, b) => a - b) const s0 = sub()
expect(s0(5, 2)).toEqual(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')).toEqual('A-B-C-D')})