-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathtap.d.ts
53 lines (53 loc) · 1.55 KB
/
tap.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
46
47
48
49
50
51
52
53
export = tap;
/**
* @name tap
*
* @synopsis
* ```coffeescript [specscript]
* tap(...args, func function) -> Promise|args[0]
* tap(func function)(...args) -> Promise|args[0]
* ```
*
* @description
* Call a function with any number of arguments, returning the first argument. Promises created by the tapper are resolved before returning the value.
*
* ```javascript [playground]
* const pipeline = pipe([
* tap(value => console.log(value)),
* tap(value => console.log(value + 'bar')),
* tap(value => console.log(value + 'barbaz')),
* ])
*
* pipeline('foo') // 'foo'
* // 'foobar'
* // 'foobarbaz'
* ```
*/
declare function tap(...args: any[]): any;
declare namespace tap {
/**
* @name tap.if
*
* @synopsis
* ```coffeescript [specscript]
* tap.if(predicate function, func function)(...args) -> Promise|args[0]
* ```
*
* @description
* A version of `tap` that accepts a predicate function (a function that returns a boolean value) before the function to execute. Only executes the function if the predicate function tests true for the same arguments provided to the execution function.
*
* ```javascript [playground]
* const isOdd = number => number % 2 == 1
*
* const logIfOdd = tap.if(
* isOdd,
* number => console.log(number, 'is an odd number')
* )
*
* logIfOdd(2)
* logIfOdd(3) // 3 is an odd number
* ```
*/
function _if(predicate: any, func: any): (...args: any[]) => any;
export { _if as if };
}