Skip to content

Commit

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

PR-URL: nodejs#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 xtx1130 committed Apr 25, 2022
1 parent 1efdc7c commit b83e81c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions doc/api/stream.md
Expand Up @@ -2532,7 +2532,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 @@ -2556,7 +2556,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 b83e81c

Please sign in to comment.