Last change
on this file since ceaed42 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
836 bytes
|
Line | |
---|
1 | var toArray = require('./toArray');
|
---|
2 |
|
---|
3 | /**
|
---|
4 | * Gets the next value on a wrapped object following the
|
---|
5 | * [iterator protocol](https://mdn.io/iteration_protocols#iterator).
|
---|
6 | *
|
---|
7 | * @name next
|
---|
8 | * @memberOf _
|
---|
9 | * @since 4.0.0
|
---|
10 | * @category Seq
|
---|
11 | * @returns {Object} Returns the next iterator value.
|
---|
12 | * @example
|
---|
13 | *
|
---|
14 | * var wrapped = _([1, 2]);
|
---|
15 | *
|
---|
16 | * wrapped.next();
|
---|
17 | * // => { 'done': false, 'value': 1 }
|
---|
18 | *
|
---|
19 | * wrapped.next();
|
---|
20 | * // => { 'done': false, 'value': 2 }
|
---|
21 | *
|
---|
22 | * wrapped.next();
|
---|
23 | * // => { 'done': true, 'value': undefined }
|
---|
24 | */
|
---|
25 | function wrapperNext() {
|
---|
26 | if (this.__values__ === undefined) {
|
---|
27 | this.__values__ = toArray(this.value());
|
---|
28 | }
|
---|
29 | var done = this.__index__ >= this.__values__.length,
|
---|
30 | value = done ? undefined : this.__values__[this.__index__++];
|
---|
31 |
|
---|
32 | return { 'done': done, 'value': value };
|
---|
33 | }
|
---|
34 |
|
---|
35 | module.exports = wrapperNext;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.