-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathand.d.ts
45 lines (45 loc) · 1.27 KB
/
and.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
export = and;
/**
* @name and
*
* @synopsis
* ```coffeescript [specscript]
* and(values Array<boolean>) -> result boolean
*
* and(...args, predicatesOrValues Array<function|boolean>) -> Promise|boolean
*
* and(predicatesOrValues Array<function|boolean>)(...args) -> Promise|boolean
* ```
*
* @description
* Tests an array of boolean values, returning true if all boolean values are truthy.
*
* ```javascript [playground]
* const oneIsLessThanThree = 1 < 3
* const twoIsGreaterThanOne = 2 > 1
* const threeIsEqualToThree = 3 === 3
*
* console.log(
* and([oneIsLessThanThree, twoIsGreaterThanOne, threeIsEqualToThree]),
* ) // true
* ```
*
* If any values in the array are synchronous or asynchronous predicate functions, `and` takes another argument to test concurrently against the predicate functions, returning true if all array values and resolved values from the predicates are truthy.
*
* ```javascript [playground]
* const isOdd = number => number % 2 == 1
*
* const isPositive = number => number > 0
*
* const isLessThan3 = number => number < 3
*
* console.log(
* and([isOdd, isPositive, isLessThan3])(1),
* ) // true
* ```
*
* @execution series
*
* @note ...args slows down here by an order of magnitude
*/
declare function and(...args: any[]): any;