Skip to main content
Module

x/rambda/either-spec.ts

Faster and smaller alternative to Ramda
Go to Latest
File
import {either} from 'rambda'
describe('R.either', () => { it('with passed type', () => { const fn = either<number>( x => x > 1, x => x % 2 === 0 ) fn // $ExpectType Predicate<number> const result = fn(2) // $ExpectType boolean result // $ExpectType boolean }) it('with passed type - curried', () => { const fn = either<number>(x => x > 1)(x => x % 2 === 0) fn // $ExpectType Predicate<number> const result = fn(2) result // $ExpectType boolean }) it('no type passed', () => { const fn = either( x => { x // $ExpectType any return x > 1 }, x => { x // $ExpectType any return x % 2 === 0 } ) const result = fn(2) result // $ExpectType boolean }) it('no type passed - curried', () => { const fn = either((x: number) => { x // $ExpectType number return x > 1 })((x: number) => { x // $ExpectType number return x % 2 === 0 }) const result = fn(2) result // $ExpectType boolean })})