Projekt

Obecné

Profil

Stáhnout (703 Bajtů) Statistiky
| Větev: | Revize:
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;
(529-529/590)