Skip to main content
Module

x/rambda/index.d.ts>cond

Faster and smaller alternative to Ramda
Go to Latest
function cond
import { cond } from "https://deno.land/x/rambda@v7.0.1/index.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 any[]
R

Parameters

conditions: Array<CondPair<T, R>>

Returns

(...args: T) => R