- Lodash - Home
- Lodash - Overview
- Lodash - Environment Setup
- Lodash - Array
- Lodash - Collection
- Lodash - Date
- Lodash - Function
- Lodash - Lang
- Lodash - Math
- Lodash - Number
- Lodash - Object
- Lodash - Seq
- Lodash - String
- Lodash - Util
- Lodash - Properties
- Lodash - Methods
- Lodash Useful Resources
- Lodash - Quick Guide
- Lodash - Useful Resources
- Lodash - Discussion
Lodash - thru method
Syntax
_.thru(value, 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.
Arguments
value (*) − The value to provide to interceptor.
interceptor (Function) − The function to invoke.
Output
(*) − Returns the result of interceptor.
Example
var _ = require('lodash');
var result = _(' abc ')
.chain()
.trim()
.thru(function(value) {
return [value];
})
.value();
console.log(result);
Save the above program in tester.js. Run the following command to execute this program.
Command
\>node tester.js
Output
[ 'abc' ]
lodash_seq.htm
Advertisements