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: #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 bengl committed Mar 21, 2022
1 parent 96dc591 commit fd7e4ab
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions doc/api/stream.md
Expand Up @@ -2469,7 +2469,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 @@ -2493,7 +2493,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 fd7e4ab

Please sign in to comment.