source:
imaps-frontend/node_modules/lodash-es/tap.js
Last change on this file was d565449, checked in by , 4 weeks ago | |
---|---|
|
|
File size: 701 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 | export default tap; |
Note:
See TracBrowser
for help on using the repository browser.