-
Notifications
You must be signed in to change notification settings - Fork 86
/
partition-spec.ts
40 lines (35 loc) · 1.11 KB
/
partition-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
import {partition} from 'rambda'
describe('R.partition', () => {
it('with array', () => {
const predicate = (x: number) => {
return x > 2
}
const list = [1, 2, 3, 4]
const result = partition(predicate, list)
const curriedResult = partition(predicate)(list)
result // $ExpectType [number[], number[]]
curriedResult // $ExpectType [number[], number[]]
})
/*
TODO
revert to old version of `dtslint` and `R.partition` typing
as there is diff between VSCode types(correct) and dtslint(incorrect)
it('with object', () => {
const predicate = (value: number, prop?: string) => {
return value > 2
}
const hash = {
a: 1,
b: 2,
c: 3,
d: 4,
}
const result = partition(predicate, hash)
const curriedResult = partition(predicate)(hash)
result[0] // $xExpectType { [key: string]: number; }
result[1] // $xExpectType { [key: string]: number; }
curriedResult[0] // $xExpectType { [key: string]: number; }
curriedResult[1] // $xExpectType { [key: string]: number; }
})
*/
})