Last change
on this file since 76712b2 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
851 bytes
|
Rev | Line | |
---|
[6a3a178] | 1 | var lodash = require('./wrapperLodash');
|
---|
| 2 |
|
---|
| 3 | /**
|
---|
| 4 | * Creates a `lodash` wrapper instance that wraps `value` with explicit method
|
---|
| 5 | * chain sequences enabled. The result of such sequences must be unwrapped
|
---|
| 6 | * with `_#value`.
|
---|
| 7 | *
|
---|
| 8 | * @static
|
---|
| 9 | * @memberOf _
|
---|
| 10 | * @since 1.3.0
|
---|
| 11 | * @category Seq
|
---|
| 12 | * @param {*} value The value to wrap.
|
---|
| 13 | * @returns {Object} Returns the new `lodash` wrapper instance.
|
---|
| 14 | * @example
|
---|
| 15 | *
|
---|
| 16 | * var users = [
|
---|
| 17 | * { 'user': 'barney', 'age': 36 },
|
---|
| 18 | * { 'user': 'fred', 'age': 40 },
|
---|
| 19 | * { 'user': 'pebbles', 'age': 1 }
|
---|
| 20 | * ];
|
---|
| 21 | *
|
---|
| 22 | * var youngest = _
|
---|
| 23 | * .chain(users)
|
---|
| 24 | * .sortBy('age')
|
---|
| 25 | * .map(function(o) {
|
---|
| 26 | * return o.user + ' is ' + o.age;
|
---|
| 27 | * })
|
---|
| 28 | * .head()
|
---|
| 29 | * .value();
|
---|
| 30 | * // => 'pebbles is 1'
|
---|
| 31 | */
|
---|
| 32 | function chain(value) {
|
---|
| 33 | var result = lodash(value);
|
---|
| 34 | result.__chain__ = true;
|
---|
| 35 | return result;
|
---|
| 36 | }
|
---|
| 37 |
|
---|
| 38 | module.exports = chain;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.