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

mapToObjectAsync-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
import {mapToObjectAsync, composeAsync} from 'rambda'
interface Output { key1: string, key2: string, key3: string,}
const list = [1, 2, 3, 12]const fn = async(x: number) => { if (x > 10) return false
return x % 2 ? {[`key${x}`]: x + 1} : {[`key${x}`]: x + 10}}
describe('R.mapToObjectAsync', () => { it('happy', async() => { const result = await mapToObjectAsync<number, Output>(fn, list) result // $ExpectType Output }) it('curried', async() => { const result = await mapToObjectAsync<number, Output>(fn)(list) result // $ExpectType Output }) it('with R.composeAsync', async() => { const result = await composeAsync( mapToObjectAsync<number, Output>(fn), (x: number[]) => x.filter((xx: number) => xx > 2) )(list)
result // $ExpectType Output })})
rambda

Version Info

Tagged at
2 months ago