Skip to main content
Module

x/rambda/pick-spec.ts

Faster and smaller alternative to Ramda
Go to Latest
File
import {pick} from 'rambda'
const input = {a: 'foo', b: 2, c: 3, d: 4}
describe('R.pick with array as props input', () => { it('without passing type', () => { const result = pick(['a', 'c'], input) result.a // $ExpectType string result.c // $ExpectType number })})
describe('R.pick with string as props input', () => { interface Input { a: string, b: number, c: number, d: number, } interface Output { a: string, c: number, } it('explicitly declare output', () => { const result = pick<Output>('a,c', input) result // $ExpectType Output result.a // $ExpectType string result.c // $ExpectType number
const curriedResult = pick<Output>('a,c')(input)
curriedResult.a // $ExpectType string })
it('explicitly declare input and output', () => { const result = pick<Input, Output>('a,c', input) result // $ExpectType Output result.a // $ExpectType string
const curriedResult = pick<Input, Output>('a,c')(input)
curriedResult.a // $ExpectType string })
it('without passing type', () => { const result = pick('a,c', input) result // $ExpectType unknown })})