deno.land / x / rambda@v9.1.1 / source / lens-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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import {lens, assoc, lensProp, view, lensIndex, lensPath} from 'rambda'
interface Input { foo: string,}const testObject: Input = { foo: 'Jazz',}
describe('R.lens', () => { it('happy', () => { const fn = lens<Input, string>((x: Input) => { x.foo // $ExpectType string return x.foo }, assoc('name')) fn // $ExpectType Lens<Input, string> })})
describe('R.lensProp', () => { it('happy', () => { const result = view<Input, string>(lensProp('foo'), testObject) result // $ExpectType string })})
describe('R.lensIndex', () => { const testList: Input[] = [{foo: 'bar'}, {foo: 'baz'}] it('happy', () => { const result = view<Input[], Input>(lensIndex(0), testList) result // $ExpectType Input result.foo // $ExpectType string })})
describe('R.lensPath', () => { const path = lensPath(['bar', 'a']) it('happy', () => { const result = view<Input, string>(path, testObject) result // $ExpectType string })})
describe('R.view', () => { const fooLens = lens<Input, string>((x: Input) => { return x.foo }, assoc('foo')) it('happt', () => { const result = view<Input, string>(fooLens, testObject) result // $ExpectType string })})
rambda

Version Info

Tagged at
2 months ago