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

x/rambda/mod.ts>cond

Faster and smaller alternative to Ramda
Go to Latest
function cond
import { cond } from "https://deno.land/x/rambda@9.2.1/mod.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