Module

x/rambda/immutable.d.ts>cond

Faster and smaller alternative to Ramda
Latest
function cond
import { cond } from "https://dotland.deno.dev/x/rambda@9.4.1/immutable.d.ts";

It takes list with conditions and returns a new function fn that expects input as argument.

This function will start evaluating the conditions in order to find the first winner(order of conditions matter).

The winner is this condition, which left side returns true when input is its argument. Then the evaluation of the right side of the winner will be the final result.

If no winner is found, then fn returns undefined.

Type Parameters

T extends readonly any[]
R

Parameters

conditions: ReadonlyArray<CondPair<T, R>>

Returns

(...args: T) => R