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

Function testLargeDataAsync

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

Source from the content-addressed store, hash-verified

208// =============================================================================
209
210async function testLargeDataAsync() {
211 const totalSize = 1024 * 1024; // 1 MB
212 const chunkSize = 16384;
213
214 async function* gen() {
215 let remaining = totalSize;
216 while (remaining > 0) {
217 const size = Math.min(chunkSize, remaining);
218 yield [Buffer.alloc(size, 0x42)]; // Fill with 'B'
219 remaining -= size;
220 }
221 }
222
223 const readable = toReadable(gen());
224 const result = await collect(readable);
225 assert.strictEqual(result.length, totalSize);
226 assert.strictEqual(result[0], 0x42);
227 assert.strictEqual(result[totalSize - 1], 0x42);
228}
229
230// =============================================================================
231// fromStreamIter: pipe to Writable

Callers 1

Calls 3

toReadableFunction · 0.85
genFunction · 0.70
collectFunction · 0.70

Tested by

no test coverage detected