ES6 generators in depth
This blog post is outdated. Please read chapter “ Generators ” in “Exploring ES6”. This blog post is part of a series on iteration in ES6: Iterables and iterators in ECMAScript 6 ES6 generators in depth Generators, a new feature of ECMAScript 6 [4] , are functions that can be paused and resumed. This helps with many applications: iterators, asynchronous programming, etc. This blog post explains how generators work and gives an overview of their applications. The following GitHub repository contains the example code: generator-examples Overview Two important applications of generators are: Implementing iterables Blocking on asynchronous function calls The following subsections give brief overviews of these applications, more thorough explanations are provided later (plus discussions of other topics). Implementing iterables via generators The following function returns an iterable over the properties of an object, one [key,value] pair per property: // The asterisk after `function` ...