Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/rambda/mod.ts>ifElse

Faster and smaller alternative to Ramda
Go to Latest
function ifElse
import { ifElse } from "https://deno.land/x/rambda@9.2.1/mod.ts";

It expects condition, onTrue and onFalse functions as inputs and it returns a new function with example name of fn.

When fn`` is called with inputargument, it will return eitheronTrue(input)oronFalse(input)depending oncondition(input)` evaluation.

Type Parameters

T
TFiltered extends T
TOnTrueResult
TOnFalseResult

Parameters

pred: (a: T) => a is TFiltered
onTrue: (a: TFiltered) => TOnTrueResult
onFalse: (a: Exclude<T, TFiltered>) => TOnFalseResult

Type Parameters

TArgs extends any[]
TOnTrueResult
TOnFalseResult

Parameters

fn: (...args: TArgs) => boolean
onTrue: (...args: TArgs) => TOnTrueResult
onFalse: (...args: TArgs) => TOnFalseResult