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

mapAsync-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
import {mapAsync, delay} from 'rambda'
const list = ['a', 'bc', 'def']const fn = async(x: string) => { await delay(100)
return x.length % 2 ? x.length + 1 : x.length + 10}const fnWithIndex = async(x: string, i: number) => { await delay(100)
return (x.length + i) % 2 ? x.length + 1 : x.length + 10}
describe('R.mapAsync', () => { it('happy', async() => { const result = await mapAsync(fn, list) result // $ExpectType number[] }) it('curried', async() => { const result = await mapAsync(fn)(list) result // $ExpectType number[] }) it('with index', async() => { const result = await mapAsync(fnWithIndex, list) result // $ExpectType number[] }) it('with index curried', async() => { const result = await mapAsync(fnWithIndex)(list) result // $ExpectType number[] })})
rambda

Version Info

Tagged at
2 months ago