Lazy, composable, and modular JavaScript
codewords.recurse.com
codewords.recurse.com
In order to get my head around all this stuff, I made a trivial little toy library using generators for basic lazy sequences, and providing some basic stuff from the lodash/underscore library for them.
I found it was enough to make a kind of wrapper class that would hold a reference to the generator function, but lazily initialise it only when client code consumed the iterator, or explicitly forced evaluation. At that point, clients are aware only of the iterable interface, and not at all of the implementation details. (Or, they wouldn't be, if the particular implementation details didn't require you to use a polyfill on 90% of browsers and VMs ;-) )
[0] https://developer.mozilla.org/en/docs/Web/JavaScript/Referen...
For good reading, have a look at the linked articles at the bottom here http://eslint.org/docs/rules/semi.html
However, this eslint rule should save you: http://eslint.org/docs/rules/no-unexpected-multiline