Loading topic
[Symbol.iterator]() method, and an iterator has a next() method that returns { value, done }. It also assumes you can read generator functions and know how JavaScript prototype chains work.2 min readnext() method that returns { value, done }. It also assumes you know that iterator helpers live on Iterator.prototype. Both topics were covered in the previous two chapters.2 min readfor...of, spread syntax, and Array.prototype.map. It also builds on the earlier chapters on Iterator.prototype and lazy evaluation.2 min readnext() protocol, and the lazy behavior of map covered in earlier chapters. Iterator.prototype.filter keeps only the values for which a predicate returns a truthy result. Like map, it returns a new iterator helper and does no work until y2 min readnext() protocol, and the lazy pull model from the earlier chapters. take(n) is the helper that lets a pipeline stop. It returns a new iterator that yields at most n values from its source and then reports done: true.2 min read{ value, done } from next(). It also assumes you know that helpers are lazy and that take limits output. drop(limit) is the opposite of take. It returns a new iterator that skips the first limit values o2 min readfor...of, and the lazy helpers map, filter, take, and drop. Those helpers return new iterators and do no work on their own. The methods covered here are different: they pull values through the pipeline and give you a final result.2 min readmap, filter, take, and drop on their own. It also assumes you know that helpers are lazy and that methods such as toArray consume an iterator. Here we combine those pieces.2 min readtake limits output, and how consuming methods such as toArray and find pull values through a pipeline. Here we put those pieces together to work safely with sequences that never end.2 min readmap and filter, generator functions, and the lazy pipelines from earlier chapters. Both APIs share method names, but they run in different orders and have different costs. This chapter shows how they differ and how to pick one.1 min readmap, filter, take, and drop, and how to consume it with toArray or spread. It covers two mistakes that catch almost everyone at first. The first is reusing an iterator that has already been consumed. The second is calling helper me2 min readmap and filter on iterators, and that arrays need .values() before you can call helpers on them.2 min readIterator.prototype, and how to chain map, filter, take, and drop. It covers what to do when the value you have does not have those helpers.2 min read.values() or generators, and that helpers are lazy: their callbacks run only when next() pulls a value. Laziness covers the work a helper does. It does not cover checking the helper's arguments. Helpers check their arguments as soon as y2 min readtry...finally inside them, and that you have used take and the consuming methods from earlier chapters.2 min readmap, take, and lazy pull-based iteration from earlier chapters, and that you can write generator functions.1 min readmap, filter, take, drop, toArray) and are comfortable with generator functions. It covers where iterator helpers are available, how to check for them at runtime, and what to do when they are missing.2 min read