From 8f91338f6eb6aa4a000c9c9858d9a5d94846c9b3 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Sat, 16 May 2020 01:38:24 +0200 Subject: [PATCH] doc: fix stream example - Un-break the code for multibyte characters - Get `fs.createReadStream` from the right module PR-URL: https://github.com/nodejs/node/pull/33426 Reviewed-By: Matteo Collina Reviewed-By: Gus Caplan Reviewed-By: Colin Ihrig --- doc/api/stream.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/api/stream.md b/doc/api/stream.md index 6229704eb91bc4..2801d2e7e8d4dd 100644 --- a/doc/api/stream.md +++ b/doc/api/stream.md @@ -1666,14 +1666,15 @@ The `pipeline` API also supports async generators: ```js const pipeline = util.promisify(stream.pipeline); -const fs = require('fs').promises; +const fs = require('fs'); async function run() { await pipeline( fs.createReadStream('lowercase.txt'), async function* (source) { + source.setEncoding('utf8'); // Work with strings rather than `Buffer`s. for await (const chunk of source) { - yield String(chunk).toUpperCase(); + yield chunk.toUpperCase(); } }, fs.createWriteStream('uppercase.txt')