UNPKG

rambdax

Version:

Extended version of Rambda - a lightweight, faster alternative to Ramda

15 lines (13 loc) 291 B
export function cond(conditions){ return input => { let done = false let toReturn conditions.forEach(([ predicate, resultClosure ]) => { if (!done && predicate(input)){ done = true toReturn = resultClosure(input) } }) return toReturn } }