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

Function testBackpressureSync

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

Source from the content-addressed store, hash-verified

421// =============================================================================
422
423async function testBackpressureSync() {
424 function* gen() {
425 for (let i = 0; i < 10; i++) {
426 yield [Buffer.from(`s${i}`)];
427 }
428 }
429
430 const readable = toReadableSync(gen(), { highWaterMark: 1 });
431
432 const chunks = [];
433 for await (const chunk of readable) {
434 chunks.push(chunk);
435 }
436
437 assert.strictEqual(chunks.length, 10);
438}
439
440// =============================================================================
441// fromStreamIterSync: backpressure within a batch

Callers 1

Calls 3

toReadableSyncFunction · 0.85
genFunction · 0.70
pushMethod · 0.45

Tested by

no test coverage detected