主题
tap
js
_.tap(value, interceptor)
此方法调用 interceptor
并返回 value
。拦截器使用一个参数调用;(value)。此方法的目的是 "利用" 方法链序列,以便修改中间结果。
¥This method invokes interceptor
and returns value
. The interceptor is invoked with one argument; (value). The purpose of this method is to "tap into" a method chain sequence in order to modify intermediate results.
新增于
¥Since
0.1.0
参数
¥Arguments
value
(*):要提供给interceptor
的值。¥
value
()*: The value to provide tointerceptor
.interceptor
(函数):要限制的函数。¥
interceptor
(Function): The function to invoke.
返回
¥Returns
(*):返回 value
。
¥()*: Returns value
.
示例
¥Example
js
_([1, 2, 3])
.tap(function(array) {
// Mutate input array.
array.pop();
})
.reverse()
.value();
// => [2, 1]