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

Function testPipeAsync

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

Source from the content-addressed store, hash-verified

232// =============================================================================
233
234async function testPipeAsync() {
235 const source = from('pipe test data');
236 const readable = toReadable(source);
237
238 const chunks = [];
239 const writable = new Writable({
240 write(chunk, enc, cb) {
241 chunks.push(chunk);
242 cb();
243 },
244 });
245
246 await new Promise((resolve, reject) => {
247 readable.pipe(writable);
248 writable.on('finish', resolve);
249 writable.on('error', reject);
250 });
251
252 assert.strictEqual(Buffer.concat(chunks).toString(), 'pipe test data');
253}
254
255// =============================================================================
256// fromStreamIter: not object mode

Callers 1

Calls 5

toReadableFunction · 0.85
concatMethod · 0.80
fromFunction · 0.50
onMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected