Expand description
Iterator helpers (27.1.4) — map, filter, take, drop, flatMap and
the terminal reduce/toArray/forEach/some/every/find, plus the
Iterator constructor and Iterator.from.
None of it existed: [1,2,3].values().map(f) was “map is not a function”.
The helpers are LAZY, which is the whole point of them — take(3) on an
endless generator has to stop after three pulls, not materialise anything.
Each is an @@native = "IteratorHelper" object holding the iterator it
draws from, so a chain is a chain of pulls; only the terminal operations
drain. That also makes them work over any iterator, including a user object
with a next method.
Constants§
- LAZY
- The lazy helpers, which return another iterator.
- METHODS
- Everything
Iterator.prototypecarries, so any iterator answers for it. - STATIC_
METHODS Iterator’s own statics.- TERMINAL
- The terminal operations, which drain the iterator and return a value.
Functions§
- call
- Dispatch a helper called on the iterator
recv. - done_
step - The
{ value: undefined, done: true }an exhausted iterator reports. - helper_
next - One step of a lazy helper: pull from the source until this stage produces a value or the source runs out.
- helper_
return - Mark a helper exhausted and close whatever it was drawing from — a
returnon any stage of a chain has to reach the generator at the bottom of it. - is_
helper - True if
nameis one of the helper methods (lazy or terminal). - static_
call Iterator.from(x).