Skip to main content

Harshal V. LADHE

JavaScript Generators

Producing sequences on demand with `function*` and `yield`, including infinite sequences, cleanup in `finally` and the iterator protocol behind them.

Content tagged generators

  • Snippet:First N Matches from Any Iterable with filter() and take()

    Get the first N matches and stop reading.
    Return the first N matches from any iterable with Iterator.from(), filter() and take(), stopping as soon as it has enough, even on infinite sequences.
    Published at:
    Categories:JavaScript
    Estimated reading time:4 min read
  • Tutorial:Iterator Helpers: Lazy Pipelines over Any Iterator

    Map, filter and take over any iterator, lazily.
    Use ES2025 iterator helpers (map, filter, take, drop, flatMap, reduce, Iterator.from) to build lazy pipelines over generators, Sets, Maps and infinite sequences.
    Published at:
    Categories:JavaScript
    Estimated reading time:10 min read