next.js 836 B

123456789101112131415161718192021222324252627282930313233343536
  1. var toArray = require('./toArray');
  2. /**
  3. * Gets the next value on a wrapped object following the
  4. * [iterator protocol](https://mdn.io/iteration_protocols#iterator).
  5. *
  6. * @name next
  7. * @memberOf _
  8. * @since 4.0.0
  9. * @category Seq
  10. * @returns {Object} Returns the next iterator value.
  11. * @example
  12. *
  13. * var wrapped = _([1, 2]);
  14. *
  15. * wrapped.next();
  16. * // => { 'done': false, 'value': 1 }
  17. *
  18. * wrapped.next();
  19. * // => { 'done': false, 'value': 2 }
  20. *
  21. * wrapped.next();
  22. * // => { 'done': true, 'value': undefined }
  23. */
  24. function wrapperNext() {
  25. if (this.__values__ === undefined) {
  26. this.__values__ = toArray(this.value());
  27. }
  28. var done = this.__index__ >= this.__values__.length,
  29. value = done ? undefined : this.__values__[this.__index__++];
  30. return { 'done': done, 'value': value };
  31. }
  32. module.exports = wrapperNext;