From 5ba2918e01ae21efdc78f0be81f10248b240f6b8 Mon Sep 17 00:00:00 2001 From: pluris Date: Mon, 14 Aug 2023 01:22:45 +0900 Subject: [PATCH 1/2] doc: add print results for examples in `WebStreams` --- doc/api/webstreams.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/doc/api/webstreams.md b/doc/api/webstreams.md index bb3374e1480e73..6eb24c5a21a8f2 100644 --- a/doc/api/webstreams.md +++ b/doc/api/webstreams.md @@ -248,6 +248,7 @@ const transformedStream = stream.pipeThrough(transform); for await (const chunk of transformedStream) console.log(chunk); + // Prints A ``` ```cjs @@ -273,6 +274,7 @@ const transformedStream = stream.pipeThrough(transform); (async () => { for await (const chunk of transformedStream) console.log(chunk); + // Prints A })(); ``` @@ -1520,6 +1522,7 @@ const dataArray = encoder.encode('hello world from consumers!'); const readable = Readable.from(dataArray); const data = await arrayBuffer(readable); console.log(`from readable: ${data.byteLength}`); +// Prints from readable: 76 ``` ```cjs @@ -1532,6 +1535,7 @@ const dataArray = encoder.encode('hello world from consumers!'); const readable = Readable.from(dataArray); arrayBuffer(readable).then((data) => { console.log(`from readable: ${data.byteLength}`); + // Prints from readable: 76 }); ``` @@ -1553,6 +1557,7 @@ const dataBlob = new Blob(['hello world from consumers!']); const readable = dataBlob.stream(); const data = await blob(readable); console.log(`from readable: ${data.size}`); +// Prints from readable: 27 ``` ```cjs @@ -1563,6 +1568,7 @@ const dataBlob = new Blob(['hello world from consumers!']); const readable = dataBlob.stream(); blob(readable).then((data) => { console.log(`from readable: ${data.size}`); + // Prints from readable: 27 }); ``` @@ -1586,6 +1592,7 @@ const dataBuffer = Buffer.from('hello world from consumers!'); const readable = Readable.from(dataBuffer); const data = await buffer(readable); console.log(`from readable: ${data.length}`); +// Prints from readable: 27 ``` ```cjs @@ -1598,6 +1605,7 @@ const dataBuffer = Buffer.from('hello world from consumers!'); const readable = Readable.from(dataBuffer); buffer(readable).then((data) => { console.log(`from readable: ${data.length}`); + // Prints from readable: 27 }); ``` @@ -1627,6 +1635,7 @@ const items = Array.from( const readable = Readable.from(JSON.stringify(items)); const data = await json(readable); console.log(`from readable: ${data.length}`); +// Prints from readable: 100 ``` ```cjs @@ -1645,6 +1654,7 @@ const items = Array.from( const readable = Readable.from(JSON.stringify(items)); json(readable).then((data) => { console.log(`from readable: ${data.length}`); + // Prints from readable: 100 }); ``` @@ -1665,6 +1675,7 @@ import { Readable } from 'node:stream'; const readable = Readable.from('Hello world from consumers!'); const data = await text(readable); console.log(`from readable: ${data.length}`); +// Prints from readable: 27 ``` ```cjs @@ -1674,6 +1685,7 @@ const { Readable } = require('node:stream'); const readable = Readable.from('Hello world from consumers!'); text(readable).then((data) => { console.log(`from readable: ${data.length}`); + // Prints from readable: 27 }); ``` From 36ef98a0c7e53f104f53b9376b4bc280bfa95dcd Mon Sep 17 00:00:00 2001 From: pluris Date: Tue, 15 Aug 2023 10:35:20 +0900 Subject: [PATCH 2/2] fixup! doc: add print results for examples in `WebStreams` --- doc/api/webstreams.md | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/doc/api/webstreams.md b/doc/api/webstreams.md index 6eb24c5a21a8f2..677f7e02b5b014 100644 --- a/doc/api/webstreams.md +++ b/doc/api/webstreams.md @@ -248,7 +248,7 @@ const transformedStream = stream.pipeThrough(transform); for await (const chunk of transformedStream) console.log(chunk); - // Prints A + // Prints: A ``` ```cjs @@ -274,7 +274,7 @@ const transformedStream = stream.pipeThrough(transform); (async () => { for await (const chunk of transformedStream) console.log(chunk); - // Prints A + // Prints: A })(); ``` @@ -412,7 +412,7 @@ async function* asyncIterableGenerator() { const stream = ReadableStream.from(asyncIterableGenerator()); for await (const chunk of stream) - console.log(chunk); // Prints 'a', 'b', 'c' + console.log(chunk); // Prints: 'a', 'b', 'c' ``` ```cjs @@ -428,7 +428,7 @@ async function* asyncIterableGenerator() { const stream = ReadableStream.from(asyncIterableGenerator()); for await (const chunk of stream) - console.log(chunk); // Prints 'a', 'b', 'c' + console.log(chunk); // Prints: 'a', 'b', 'c' })(); ``` @@ -1522,7 +1522,7 @@ const dataArray = encoder.encode('hello world from consumers!'); const readable = Readable.from(dataArray); const data = await arrayBuffer(readable); console.log(`from readable: ${data.byteLength}`); -// Prints from readable: 76 +// Prints: from readable: 76 ``` ```cjs @@ -1535,7 +1535,7 @@ const dataArray = encoder.encode('hello world from consumers!'); const readable = Readable.from(dataArray); arrayBuffer(readable).then((data) => { console.log(`from readable: ${data.byteLength}`); - // Prints from readable: 76 + // Prints: from readable: 76 }); ``` @@ -1557,7 +1557,7 @@ const dataBlob = new Blob(['hello world from consumers!']); const readable = dataBlob.stream(); const data = await blob(readable); console.log(`from readable: ${data.size}`); -// Prints from readable: 27 +// Prints: from readable: 27 ``` ```cjs @@ -1568,7 +1568,7 @@ const dataBlob = new Blob(['hello world from consumers!']); const readable = dataBlob.stream(); blob(readable).then((data) => { console.log(`from readable: ${data.size}`); - // Prints from readable: 27 + // Prints: from readable: 27 }); ``` @@ -1592,7 +1592,7 @@ const dataBuffer = Buffer.from('hello world from consumers!'); const readable = Readable.from(dataBuffer); const data = await buffer(readable); console.log(`from readable: ${data.length}`); -// Prints from readable: 27 +// Prints: from readable: 27 ``` ```cjs @@ -1605,7 +1605,7 @@ const dataBuffer = Buffer.from('hello world from consumers!'); const readable = Readable.from(dataBuffer); buffer(readable).then((data) => { console.log(`from readable: ${data.length}`); - // Prints from readable: 27 + // Prints: from readable: 27 }); ``` @@ -1635,7 +1635,7 @@ const items = Array.from( const readable = Readable.from(JSON.stringify(items)); const data = await json(readable); console.log(`from readable: ${data.length}`); -// Prints from readable: 100 +// Prints: from readable: 100 ``` ```cjs @@ -1654,7 +1654,7 @@ const items = Array.from( const readable = Readable.from(JSON.stringify(items)); json(readable).then((data) => { console.log(`from readable: ${data.length}`); - // Prints from readable: 100 + // Prints: from readable: 100 }); ``` @@ -1675,7 +1675,7 @@ import { Readable } from 'node:stream'; const readable = Readable.from('Hello world from consumers!'); const data = await text(readable); console.log(`from readable: ${data.length}`); -// Prints from readable: 27 +// Prints: from readable: 27 ``` ```cjs @@ -1685,7 +1685,7 @@ const { Readable } = require('node:stream'); const readable = Readable.from('Hello world from consumers!'); text(readable).then((data) => { console.log(`from readable: ${data.length}`); - // Prints from readable: 27 + // Prints: from readable: 27 }); ```