主题
thru
js
_.thru(value, interceptor)
此方法与 _.tap
类似,不同之处在于它返回 interceptor
的结果。此方法的目的是 "通过" 值替换方法链序列中的中间结果。
¥This method is like _.tap
except that it returns the result of interceptor
. The purpose of this method is to "pass thru" values replacing intermediate results in a method chain sequence.
新增于
¥Since
3.0.0
参数
¥Arguments
value
(*):要提供给interceptor
的值。¥
value
()*: The value to provide tointerceptor
.interceptor
(函数):要限制的函数。¥
interceptor
(Function): The function to invoke.
返回
¥Returns
(*):返回 interceptor
的结果。
¥()*: Returns the result of interceptor
.
示例
¥Example
js
_(' abc ')
.chain()
.trim()
.thru(function(value) {
return [value];
})
.value();
// => ['abc']