Last change
on this file since 188ee53 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
703 bytes
|
Line | |
---|
1 | /**
|
---|
2 | * This method invokes `interceptor` and returns `value`. The interceptor
|
---|
3 | * is invoked with one argument; (value). The purpose of this method is to
|
---|
4 | * "tap into" a method chain sequence in order to modify intermediate results.
|
---|
5 | *
|
---|
6 | * @static
|
---|
7 | * @memberOf _
|
---|
8 | * @since 0.1.0
|
---|
9 | * @category Seq
|
---|
10 | * @param {*} value The value to provide to `interceptor`.
|
---|
11 | * @param {Function} interceptor The function to invoke.
|
---|
12 | * @returns {*} Returns `value`.
|
---|
13 | * @example
|
---|
14 | *
|
---|
15 | * _([1, 2, 3])
|
---|
16 | * .tap(function(array) {
|
---|
17 | * // Mutate input array.
|
---|
18 | * array.pop();
|
---|
19 | * })
|
---|
20 | * .reverse()
|
---|
21 | * .value();
|
---|
22 | * // => [2, 1]
|
---|
23 | */
|
---|
24 | function tap(value, interceptor) {
|
---|
25 | interceptor(value);
|
---|
26 | return value;
|
---|
27 | }
|
---|
28 |
|
---|
29 | module.exports = tap;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.