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

Function testDestroySync

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

Source from the content-addressed store, hash-verified

491// =============================================================================
492
493async function testDestroySync() {
494 let returnCalled = false;
495 function* gen() {
496 try {
497 for (let i = 0; ; i++) {
498 yield [Buffer.from(`chunk${i}`)];
499 }
500 } finally {
501 returnCalled = true;
502 }
503 }
504
505 const readable = toReadableSync(gen());
506 readable.read(); // Start iteration
507 readable.destroy();
508
509 await new Promise((resolve) => readable.on('close', resolve));
510 assert.ok(returnCalled, 'iterator.return() should have been called');
511}
512
513// =============================================================================
514// fromStreamIterSync: not object mode

Callers 1

Calls 6

toReadableSyncFunction · 0.85
genFunction · 0.70
readMethod · 0.45
destroyMethod · 0.45
onMethod · 0.45
okMethod · 0.45

Tested by

no test coverage detected