Infinite collections with ES6 generators
This repo contains some demonstration code samples on how to use ES6 generators.
Hand-creating iterators requires boilerplate, but it is the basis for generators. You can create infinite collections easily.
Generators are syntax sugar on top of iterators, but they make them a whole lot simpler and readable.
Infinite collections come handy when you don't know how many elements you'll need in advance. This sample demonstrates this problem.
When you want to sum the first 100 positive numbers, you know you'll need 100 elements. But what if you want to sum the first 100 primes?
You can create infinite collections using generators. With the help of the Gentoo library (among others) you can write terse and readable functions.