deno.land / x / rambda@v9.1.1 / source / when-spec.ts

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import {when} from 'rambda'
const predicate = (x: number) => x > 2const whenTrueFn = (x: number) => String(x)
describe('R.when', () => { it('happy', () => { const result = when(predicate, whenTrueFn, 1) result // $ExpectType string | 1 })
it('curry 1', () => { const fn = when(predicate, whenTrueFn) const result = fn(1) result // $ExpectType string | number })
it('curry 2 require explicit types', () => { const fn = when<number, string>(predicate)(whenTrueFn) const result = fn(1) result // $ExpectType string | number })})
rambda

Version Info

Tagged at
2 months ago