summaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/lodash/chain/tap.js
blob: 3d0257ecfde69bf003065ec8fb7b6d789c9c5148 (plain)
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
/**
 * This method invokes `interceptor` and returns `value`. The interceptor is
 * bound to `thisArg` and invoked with one argument; (value). The purpose of
 * this method is to "tap into" a method chain in order to perform operations
 * on intermediate results within the chain.
 *
 * @static
 * @memberOf _
 * @category Chain
 * @param {*} value The value to provide to `interceptor`.
 * @param {Function} interceptor The function to invoke.
 * @param {*} [thisArg] The `this` binding of `interceptor`.
 * @returns {*} Returns `value`.
 * @example
 *
 * _([1, 2, 3])
 *  .tap(function(array) {
 *    array.pop();
 *  })
 *  .reverse()
 *  .value();
 * // => [2, 1]
 */
function tap(value, interceptor, thisArg) {
  interceptor.call(thisArg, value);
  return value;
}

module.exports = tap;