ES6 generators

Erik Soehnel
github.com/hoeck

what am I talking about?


function* gen () {
    for (let i=0; i<2; i++) {
        yield i;
    }
}

const g = gen();

g.next() // => { value: 0, done: false }
g.next() // => { value: 1, done: false }
g.next() // => { value: undefined, done: true }
// done
                    

this is a generator function

and this is how we use them

by the end of this talk, you'll know how to use *`yield`*