Attempt to use generators to create lazy iterators. Similar to the Java 8 Streams API, C# Enumerable, Rust iterator, F# and Kotlin Sequences, etc.
For a fully featured library with similar aims, try out sequency https://github.com/winterbe/streamjs or streamjs https://github.com/winterbe/streamjs