Skip to main content
Module

x/rambda/ifElse-spec.ts

Faster and smaller alternative to Ramda
Go to Latest
File
import {ifElse} from 'rambda'
describe('R.ifElse', () => { it('happy', () => { const condition = (x: number) => x > 5 const onTrue = (x: number) => `foo${x}` const onFalse = (x: number) => `bar${x}` const fn = ifElse(condition, onTrue, onFalse) fn // $ExpectType (x: number) => string const result = fn(3) result // $ExpectType string }) it('arity of 2', () => { const condition = (x: number, y: string) => x + y.length > 5 const onTrue = (x: number, y: string) => `foo${x}-${y}` const onFalse = (x: number, y: string) => `bar${x}-${y}` const fn = ifElse(condition, onTrue, onFalse) fn // $ExpectType (x: number, y: string) => string const result = fn(3, 'hello') result // $ExpectType string })})