Skip to main content
Module

x/lodash_es/mod.ts>cond

lodash for deno use
Latest
function cond
import { cond } from "https://deno.land/x/lodash_es@v0.0.2/mod.ts";

Creates a function that iterates over pairs and invokes the corresponding function of the first predicate to return truthy. The predicate-function pairs are invoked with the this binding and arguments of the created function.

Examples

var func = .cond([ [.matches({ 'a': 1 }), .constant('matches A')], [.conforms({ 'b': _.isNumber }), .constant('matches B')], [.stubTrue, _.constant('no match')] ]);

func({ 'a': 1, 'b': 2 }); // => 'matches A'

func({ 'a': 0, 'b': 1 }); // => 'matches B'

func({ 'a': '1', 'b': '2' }); // => 'no match'

Parameters

pairs

The predicate-function pairs.