Skip to content

Commit 21949c4

Browse files
Jungku LeeRafaelGSS
Jungku Lee
authored andcommitted
doc: add print results for examples in WebStreams
PR-URL: #49143 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Deokjin Kim <deokjin81.kim@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 750cca2 commit 21949c4

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

doc/api/webstreams.md

+14-2
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ const transformedStream = stream.pipeThrough(transform);
248248

249249
for await (const chunk of transformedStream)
250250
console.log(chunk);
251+
// Prints: A
251252
```
252253

253254
```cjs
@@ -273,6 +274,7 @@ const transformedStream = stream.pipeThrough(transform);
273274
(async () => {
274275
for await (const chunk of transformedStream)
275276
console.log(chunk);
277+
// Prints: A
276278
})();
277279
```
278280

@@ -410,7 +412,7 @@ async function* asyncIterableGenerator() {
410412
const stream = ReadableStream.from(asyncIterableGenerator());
411413

412414
for await (const chunk of stream)
413-
console.log(chunk); // Prints 'a', 'b', 'c'
415+
console.log(chunk); // Prints: 'a', 'b', 'c'
414416
```
415417

416418
```cjs
@@ -426,7 +428,7 @@ async function* asyncIterableGenerator() {
426428
const stream = ReadableStream.from(asyncIterableGenerator());
427429

428430
for await (const chunk of stream)
429-
console.log(chunk); // Prints 'a', 'b', 'c'
431+
console.log(chunk); // Prints: 'a', 'b', 'c'
430432
})();
431433
```
432434

@@ -1520,6 +1522,7 @@ const dataArray = encoder.encode('hello world from consumers!');
15201522
const readable = Readable.from(dataArray);
15211523
const data = await arrayBuffer(readable);
15221524
console.log(`from readable: ${data.byteLength}`);
1525+
// Prints: from readable: 76
15231526
```
15241527
15251528
```cjs
@@ -1532,6 +1535,7 @@ const dataArray = encoder.encode('hello world from consumers!');
15321535
const readable = Readable.from(dataArray);
15331536
arrayBuffer(readable).then((data) => {
15341537
console.log(`from readable: ${data.byteLength}`);
1538+
// Prints: from readable: 76
15351539
});
15361540
```
15371541
@@ -1553,6 +1557,7 @@ const dataBlob = new Blob(['hello world from consumers!']);
15531557
const readable = dataBlob.stream();
15541558
const data = await blob(readable);
15551559
console.log(`from readable: ${data.size}`);
1560+
// Prints: from readable: 27
15561561
```
15571562
15581563
```cjs
@@ -1563,6 +1568,7 @@ const dataBlob = new Blob(['hello world from consumers!']);
15631568
const readable = dataBlob.stream();
15641569
blob(readable).then((data) => {
15651570
console.log(`from readable: ${data.size}`);
1571+
// Prints: from readable: 27
15661572
});
15671573
```
15681574
@@ -1586,6 +1592,7 @@ const dataBuffer = Buffer.from('hello world from consumers!');
15861592
const readable = Readable.from(dataBuffer);
15871593
const data = await buffer(readable);
15881594
console.log(`from readable: ${data.length}`);
1595+
// Prints: from readable: 27
15891596
```
15901597
15911598
```cjs
@@ -1598,6 +1605,7 @@ const dataBuffer = Buffer.from('hello world from consumers!');
15981605
const readable = Readable.from(dataBuffer);
15991606
buffer(readable).then((data) => {
16001607
console.log(`from readable: ${data.length}`);
1608+
// Prints: from readable: 27
16011609
});
16021610
```
16031611
@@ -1627,6 +1635,7 @@ const items = Array.from(
16271635
const readable = Readable.from(JSON.stringify(items));
16281636
const data = await json(readable);
16291637
console.log(`from readable: ${data.length}`);
1638+
// Prints: from readable: 100
16301639
```
16311640
16321641
```cjs
@@ -1645,6 +1654,7 @@ const items = Array.from(
16451654
const readable = Readable.from(JSON.stringify(items));
16461655
json(readable).then((data) => {
16471656
console.log(`from readable: ${data.length}`);
1657+
// Prints: from readable: 100
16481658
});
16491659
```
16501660
@@ -1665,6 +1675,7 @@ import { Readable } from 'node:stream';
16651675
const readable = Readable.from('Hello world from consumers!');
16661676
const data = await text(readable);
16671677
console.log(`from readable: ${data.length}`);
1678+
// Prints: from readable: 27
16681679
```
16691680
16701681
```cjs
@@ -1674,6 +1685,7 @@ const { Readable } = require('node:stream');
16741685
const readable = Readable.from('Hello world from consumers!');
16751686
text(readable).then((data) => {
16761687
console.log(`from readable: ${data.length}`);
1688+
// Prints: from readable: 27
16771689
});
16781690
```
16791691

0 commit comments

Comments
 (0)