Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
80742 views
1
/**
2
* This method is like `_.tap` except that it returns the result of `interceptor`.
3
*
4
* @static
5
* @memberOf _
6
* @category Chain
7
* @param {*} value The value to provide to `interceptor`.
8
* @param {Function} interceptor The function to invoke.
9
* @param {*} [thisArg] The `this` binding of `interceptor`.
10
* @returns {*} Returns the result of `interceptor`.
11
* @example
12
*
13
* _(' abc ')
14
* .chain()
15
* .trim()
16
* .thru(function(value) {
17
* return [value];
18
* })
19
* .value();
20
* // => ['abc']
21
*/
22
function thru(value, interceptor, thisArg) {
23
return interceptor.call(thisArg, value);
24
}
25
26
module.exports = thru;
27
28