-
-
Notifications
You must be signed in to change notification settings - Fork 245
Open
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().
Metadata
Metadata
Assignees
Labels
No labels