Add thisArg to _.tap.

This commit is contained in:
John-David Dalton
2013-12-16 02:34:20 -08:00
parent 6845a52e92
commit 172cc1ffea
6 changed files with 48 additions and 29 deletions

View File

@@ -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;
}