Skip to content

Commit 31cd044

Browse files
committed
1
1 parent c5524e4 commit 31cd044

2 files changed

Lines changed: 21 additions & 4 deletions

File tree

files/index.d.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4836,13 +4836,17 @@ export function flattenObject<T extends object>(obj: T): FlattenObject<T>;
48364836
/*
48374837
Method: shuffle
48384838
4839-
Explanation: It returns a randomized copy of array.
4839+
Explanation: It returns a randomized copy of array.
48404840
48414841
Example:
48424842
48434843
```
4844-
const result = R.shuffle(
4845-
[1, 2, 3]
4844+
const data = Array.from({ length: 100 }, (_, i) => i + 1)
4845+
const result = await pipe(
4846+
data,
4847+
shuffle<number>, // NEEDS EXPLICIT TYPE ANNOTATION
4848+
splitEvery(10),
4849+
flatMap(String),
48464850
)
48474851
// => [3, 1, 2] or [2, 3, 1] or ...
48484852
```

source/splitEvery-spec.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { pipe, splitEvery } from 'rambda'
1+
import { flatMap, pipe, shuffle, splitEvery } from 'rambda'
22
import { describe, expectTypeOf, it } from 'vitest'
33

44
const list = [1, 2, 3, 4, 5, 6, 7]
@@ -8,4 +8,17 @@ describe('R.splitEvery', () => {
88
const result = pipe(list, splitEvery(3))
99
expectTypeOf(result).toEqualTypeOf<number[][]>()
1010
})
11+
it('async', async () => {
12+
const data = Array.from({ length: 100 }, (_, i) => i + 1)
13+
const result = await pipe(
14+
data,
15+
shuffle<number>, // NEEDS EXPLICIT TYPE ANNOTATION
16+
// (list) => shuffle(list), // THIS ALSO WORKS
17+
// shuffle, THIS IS NOT WORKING `TypeScript cannot infer types backward and forward at the exact same time`
18+
splitEvery(10),
19+
flatMap(String),
20+
)
21+
22+
expectTypeOf(result).toEqualTypeOf<string[]>()
23+
})
1124
})

0 commit comments

Comments
 (0)