mirror of
https://github.com/idanoo/GoScrobble.git
synced 2024-11-24 09:25:15 +00:00
36 lines
834 B
JavaScript
36 lines
834 B
JavaScript
|
import toArray from './toArray.js';
|
||
|
|
||
|
/**
|
||
|
* Gets the next value on a wrapped object following the
|
||
|
* [iterator protocol](https://mdn.io/iteration_protocols#iterator).
|
||
|
*
|
||
|
* @name next
|
||
|
* @memberOf _
|
||
|
* @since 4.0.0
|
||
|
* @category Seq
|
||
|
* @returns {Object} Returns the next iterator value.
|
||
|
* @example
|
||
|
*
|
||
|
* var wrapped = _([1, 2]);
|
||
|
*
|
||
|
* wrapped.next();
|
||
|
* // => { 'done': false, 'value': 1 }
|
||
|
*
|
||
|
* wrapped.next();
|
||
|
* // => { 'done': false, 'value': 2 }
|
||
|
*
|
||
|
* wrapped.next();
|
||
|
* // => { 'done': true, 'value': undefined }
|
||
|
*/
|
||
|
function wrapperNext() {
|
||
|
if (this.__values__ === undefined) {
|
||
|
this.__values__ = toArray(this.value());
|
||
|
}
|
||
|
var done = this.__index__ >= this.__values__.length,
|
||
|
value = done ? undefined : this.__values__[this.__index__++];
|
||
|
|
||
|
return { 'done': done, 'value': value };
|
||
|
}
|
||
|
|
||
|
export default wrapperNext;
|