Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
doc: fix async iterable pipeline signal examples
Fix the pipeline examples to show that async generators receive
an AbortSignal wrapped in an object.

PR-URL: #42258
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
  • Loading branch information
tilgovi authored and danielleadams committed Apr 24, 2022
1 parent 3188dcb commit 4f6b187
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions doc/api/stream.md
Expand Up @@ -2419,7 +2419,7 @@ const fs = require('fs');
async function run() {
await pipeline(
fs.createReadStream('lowercase.txt'),
async function* (source, signal) {
async function* (source, { signal }) {
source.setEncoding('utf8'); // Work with strings rather than `Buffer`s.
for await (const chunk of source) {
yield await processChunk(chunk, { signal });
Expand All @@ -2443,7 +2443,7 @@ const fs = require('fs');

async function run() {
await pipeline(
async function * (signal) {
async function* ({ signal }) {
await someLongRunningfn({ signal });
yield 'asd';
},
Expand Down

0 comments on commit 4f6b187

Please sign in to comment.