Skip to content

Commit f1354af

Browse files
tilgovidanielleadams
authored andcommitted
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>
1 parent 9ebb5bd commit f1354af

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

doc/api/stream.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2419,7 +2419,7 @@ const fs = require('fs');
24192419
async function run() {
24202420
await pipeline(
24212421
fs.createReadStream('lowercase.txt'),
2422-
async function* (source, signal) {
2422+
async function* (source, { signal }) {
24232423
source.setEncoding('utf8'); // Work with strings rather than `Buffer`s.
24242424
for await (const chunk of source) {
24252425
yield await processChunk(chunk, { signal });
@@ -2443,7 +2443,7 @@ const fs = require('fs');
24432443

24442444
async function run() {
24452445
await pipeline(
2446-
async function * (signal) {
2446+
async function* ({ signal }) {
24472447
await someLongRunningfn({ signal });
24482448
yield 'asd';
24492449
},

0 commit comments

Comments
 (0)