main
Last change
on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
849 bytes
|
Line | |
---|
1 | import lodash from './wrapperLodash.js';
|
---|
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 | export default chain;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.