Create an independent clone of the iterator.
A new independent clone of the iterator.
The cloned iterator can be consumed independently of the current iterator. In essence, it is a copy of the iterator value stream which starts at the current location.
This can be useful for lookahead and stream duplication.
Get an iterator over the object's values.
An iterator which yields the object's values.
Depending on the iterable, the returned iterator may or may not be
a new object. A collection or other container-like object should
typically return a new iterator, while an iterator itself should
normally return this
.
Get the next value from the iterator.
The next value from the iterator, or undefined
.
The undefined
value is used to signal the end of iteration and
should therefore not be used as a value in a collection.
The use of the undefined
sentinel is an explicit design choice
which favors performance over purity. The ES6 iterator design of
returning a { value, done }
pair is suboptimal, as it requires
an object allocation on each iteration; and an isDone()
method
would increase implementation and runtime complexity.
Generated using TypeDoc
An object which traverses a collection of values.
Notes
An
IIterator
is itself anIIterable
. Most implementations ofIIterator
should simply returnthis
from theiter()
method.