Skip to content
HTML
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
README.md
generators.html
gentoo.html
index.html
iterator.html
primes.html

README.md

Infinite collections with ES6 generators

This repo contains some demonstration code samples on how to use ES6 generators.

Read more at https://advancedweb.hu/2016/05/31/infinite-collections-with-es6-generators/ .

Iterators

Hand-creating iterators requires boilerplate, but it is the basis for generators. You can create infinite collections easily.

http://sashee.github.io/infinite-collections-with-es6-generators/iterator.html

Generators

Generators are syntax sugar on top of iterators, but they make them a whole lot simpler and readable.

http://sashee.github.io/infinite-collections-with-es6-generators/generators.html

Infinite collections

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?

http://sashee.github.io/infinite-collections-with-es6-generators/primes.html

Gentoo library

You can create infinite collections using generators. With the help of the Gentoo library (among others) you can write terse and readable functions.

http://sashee.github.io/infinite-collections-with-es6-generators/gentoo.html

You can’t perform that action at this time.