Add support for multiple predicates to is.any (#104)

This commit is contained in:
Dave Cohen 2020-02-16 19:06:19 -06:00 committed by GitHub
parent f97029fd73
commit d1929ad47c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 5 deletions

View file

@ -420,9 +420,9 @@ Returns `true` if `value` is an even integer.
Returns `true` if `value` is an odd integer.
##### .any(predicate, ...values)
##### .any(predicate | predicate[], ...values)
Returns `true` if **any** of the input `values` returns true in the `predicate`:
Using a single `predicate` argument, returns `true` if **any** of the input `values` returns true in the `predicate`:
```js
is.any(is.string, {}, true, '🦄');
@ -432,6 +432,16 @@ is.any(is.boolean, 'unicorns', [], new Map());
//=> false
```
Using an array of `predicate[]`, returns `true` if **any** of the input `values` returns true for **any** of the `predicates` provided in an array:
```js
is.any([is.string, is.number], {}, true, '🦄');
//=> true
is.any([is.boolean, is.number], 'unicorns', [], new Map());
//=> false
```
##### .all(predicate, ...values)
Returns `true` if **all** of the input `values` returns true in the `predicate`: