sindresorhus / sindresorhus/execa

Document and test async iterator helpers

Open
#1,001 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
7.6k
Forks
570
PR merge metrics
No merged PRs in 30d

Description

Synchronous iterator helpers just landed in Node 22. Async iterator helpers are currently a stage 2 ES proposal. Once they land in Node, we should add some tests, and document how to use them with Execa.

They could be quite nice to use with Execa. For example:

for await (const line of execa`npm run build`.iterable().map(line => line.toUpperCase()) {
  // ...
}
for await (const line of execa`npm run build`.iterable().filter(line => !line.includes('secret')) {
  // ...
}
// First 3 lines of output only
for await (const line of execa`npm run build`.iterable().take(3)) {
  // `return` or `break` inside this loop will still await for the subprocess completion, which is good
  // ...
}

Note: iterable.some(), iterable.every() and iterable.find() would also be useful to get a quick return value while the subprocess is still running. However, those won't wait for the subprocess to complete, so the user would need to call await subprocess, unlike the other iterator methods.

Also, those could be used with getEachMessage().

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by checking Node 22 support for async iterator helpers and the linked TC39 proposal. Then inspect Execa's iterable() and getEachMessage() entry points. Done means documented examples for map, filter, take, some, every, and find, with tests covering the supported behavior once the helpers land.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
api, documentation, testing-qa
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.