MCPcopy Index your code
hub / github.com/nodejs/node / testDelayedPushes

Function testDelayedPushes

test/parallel/test-stream-iter-readable-interop.js:135–153  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

133// =============================================================================
134
135async function testDelayedPushes() {
136 let pushCount = 0;
137 const readable = new Readable({
138 read() {
139 if (pushCount < 3) {
140 setTimeout(() => {
141 this.push(Buffer.from(`delayed${pushCount}`));
142 pushCount++;
143 if (pushCount === 3) {
144 this.push(null);
145 }
146 }, 10);
147 }
148 },
149 });
150
151 const result = await text(from(readable));
152 assert.strictEqual(result, 'delayed0delayed1delayed2');
153}
154
155// =============================================================================
156// Byte-mode Readable: empty stream

Calls 2

textFunction · 0.50
fromFunction · 0.50

Tested by

no test coverage detected