mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-12 20:07:49 +00:00
Add thisArg to _.tap.
This commit is contained in:
17
dist/lodash.js
vendored
17
dist/lodash.js
vendored
@@ -2646,7 +2646,7 @@
|
||||
* per iteration. If a property name or object is provided it will be used
|
||||
* to create a "_.pluck" or "_.where" style callback, respectively.
|
||||
* @param {*} [thisArg] The `this` binding of `callback`.
|
||||
* @returns {Array} Returns a new object with values of the results of each `callback` execution.
|
||||
* @returns {Object} Returns a new object with values of the results of each `callback` execution.
|
||||
* @example
|
||||
*
|
||||
* _.mapValues({ 'a': 1, 'b': 2, 'c': 3} , function(num) { return num * 3; });
|
||||
@@ -3875,7 +3875,7 @@
|
||||
* @param {number} [n] The number of elements to sample.
|
||||
* @param- {Object} [guard] Allows working with functions like `_.map`
|
||||
* without using their `index` arguments as `n`.
|
||||
* @returns {Array} Returns the random sample(s) of `collection`.
|
||||
* @returns {*} Returns the random sample(s) of `collection`.
|
||||
* @example
|
||||
*
|
||||
* _.sample([1, 2, 3, 4]);
|
||||
@@ -6506,16 +6506,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
|
||||
*
|
||||
@@ -6525,8 +6526,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