MCPcopy Create free account
hub / github.com/nodejs/node / testBackpressureAsync

Function testBackpressureAsync

test/parallel/test-stream-iter-to-readable.js:67–86  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

65// =============================================================================
66
67async function testBackpressureAsync() {
68 let batchCount = 0;
69 async function* gen() {
70 for (let i = 0; i < 10; i++) {
71 batchCount++;
72 yield [Buffer.from(`chunk${i}`)];
73 }
74 }
75
76 const readable = toReadable(gen(), { highWaterMark: 1 });
77
78 // Read one chunk at a time with delays to exercise backpressure
79 const chunks = [];
80 for await (const chunk of readable) {
81 chunks.push(chunk);
82 }
83
84 assert.strictEqual(chunks.length, 10);
85 assert.strictEqual(batchCount, 10);
86}
87
88// =============================================================================
89// fromStreamIter: source error mid-stream

Callers 1

Calls 3

toReadableFunction · 0.85
genFunction · 0.70
pushMethod · 0.45

Tested by

no test coverage detected