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

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

Version Info

Tagged at
2 months ago