I don&#x27;t think this is strictly true: if your parser module also implemented the iterator&#x2F;iterable protocols[0], then you could compose them that way. That may or may not be good enough for a particular use case.<p>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&#x2F;underscore library for them.<p>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&#x27;t be, if the <i>particular</i> implementation details didn&#x27;t require you to use a polyfill on 90% of browsers and VMs ;-) )<p>[0] <a href="https:&#x2F;&#x2F;developer.mozilla.org&#x2F;en&#x2F;docs&#x2F;Web&#x2F;JavaScript&#x2F;Reference&#x2F;Iteration_protocols" rel="nofollow">https:&#x2F;&#x2F;developer.mozilla.org&#x2F;en&#x2F;docs&#x2F;Web&#x2F;JavaScript&#x2F;Referen...</a>