Skip to content

when

Summary

Returns fn(...x) if pred(...x) has returned logical true. Otherwise returns undefined.

Tip

This function is curried.

Examples

1
2
3
4
5
when(eq(40), add(2))(40);
//=> 42

when(eq(40), add(2))(41);
//=> undefined

Parameters

Name Type Description
pred function Predicate. Must return logical true.
fn function Function applied to the arguments if predicate is satisfied
x ? One or more arguments

Return

?