Files
lodash/chain.js
John-David Dalton 54e7baecc3 Bump to v4.0.0.
2016-01-12 00:17:29 -08:00

37 lines
816 B
JavaScript

import lodash from './wrapperLodash';
/**
* Creates a `lodash` object that wraps `value` with explicit method chaining enabled.
* The result of such method chaining must be unwrapped with `_#value`.
*
* @static
* @memberOf _
* @category Seq
* @param {*} 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'
*/
function chain(value) {
var result = lodash(value);
result.__chain__ = true;
return result;
}
export default chain;