Projekt

Obecné

Profil

Stáhnout (836 Bajtů) Statistiky
| Větev: | Revize:
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;
(426-426/571)