all
Summary
Returns true if predicate passed for all elements of the list.
Tip
This function is curried.
Examples
Returns true if all elements of a list are equal to x:
1 2 3 4 5 6 7 8 9 10 11
const allx = all(eq('x'));
// Checking arrays
allx(['x']); //=> true
allx(['x', 'x']); //=> true
allx(['x', 'y', 'x']); //=> false
// Checking objects
allx({a:'x'}); //=> true
allx({a:'x', b: 'x'}); //=> true
allx({a:'x', b: 'y', c: 'x'}); //=> false
Parameters
| Name | Type | Description |
|---|---|---|
| pred | function |
Predicate |
| xs | Array or Object |
List of values |
Return
boolean