chain source
_.chain(value)
Creates a lodash
object that wraps value
with explicit method chaining enabled.
The result of such method chaining must be unwrapped with _#value
.
Arguments
- value (*)
The value to wrap.
Returns (Object)
Returns the new lodash
wrapper instance.
Example
var users = [
{ 'user': 'barney', 'age': 36 },
{ 'user': 'fred', 'age': 40 },
{ 'user': 'pebbles', 'age': 1 }
];
var youngest = _
.chain(users)
.sortBy('age')
.map(function(o) {
return o.user + ' is ' + o.age;
})
.head()
.value();
// => 'pebbles is 1'