mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-12 03:47:50 +00:00
Add thisArg to _.tap.
This commit is contained in:
13
lodash.js
13
lodash.js
@@ -6842,16 +6842,17 @@
|
||||
}
|
||||
|
||||
/**
|
||||
* Invokes `interceptor` with the `value` as the first argument and then
|
||||
* returns `value`. The purpose of this method is to "tap into" a method
|
||||
* chain in order to perform operations on intermediate results within
|
||||
* the chain.
|
||||
* 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 Chaining
|
||||
* @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
|
||||
*
|
||||
@@ -6861,8 +6862,8 @@
|
||||
* .value();
|
||||
* // => [3, 2, 1]
|
||||
*/
|
||||
function tap(value, interceptor) {
|
||||
interceptor(value);
|
||||
function tap(value, interceptor, thisArg) {
|
||||
interceptor.call(thisArg, value);
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user