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

sortBy-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
import {sortBy, pipe} from 'rambda'
interface Input { a: number,}
describe('R.sortBy', () => { it('passing type to sort function', () => { function fn(x: any): number { return x.a } function fn2(x: Input): number { return x.a }
const input = [{a: 2}, {a: 1}, {a: 0}] const result = sortBy(fn, input) const curriedResult = sortBy(fn2)(input)
result // $ExpectType { a: number; }[] curriedResult // $ExpectType Input[] result[0].a // $ExpectType number curriedResult[0].a // $ExpectType number }) it('passing type to sort function and list', () => { function fn(x: Input): number { return x.a }
const input: Input[] = [{a: 2}, {a: 1}, {a: 0}] const result = sortBy(fn, input) const curriedResult = sortBy(fn)(input)
result // $ExpectType Input[] curriedResult // $ExpectType Input[] result[0].a // $ExpectType number }) it('with R.pipe', () => { interface Obj { value: number, } const fn = pipe(sortBy<Obj>(x => x.value))
const result = fn([{value: 1}, {value: 2}]) result // $ExpectType Obj[] })})
rambda

Version Info

Tagged at
2 months ago