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

Function testWithTransformAsync

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

Source from the content-addressed store, hash-verified

370// =============================================================================
371
372async function testWithTransformAsync() {
373 // Uppercase transform
374 function upper(chunks) {
375 if (chunks === null) return null;
376 return chunks.map((c) => {
377 const buf = Buffer.from(c);
378 for (let i = 0; i < buf.length; i++) {
379 if (buf[i] >= 97 && buf[i] <= 122) buf[i] -= 32;
380 }
381 return buf;
382 });
383 }
384
385 const source = pull(from('hello world'), upper);
386 const readable = toReadable(source);
387 const result = await collect(readable);
388 assert.strictEqual(result.toString(), 'HELLO WORLD');
389}
390
391// =============================================================================
392// fromStreamIterSync: basic sync round-trip

Callers 1

Calls 5

toReadableFunction · 0.85
pullFunction · 0.70
collectFunction · 0.70
fromFunction · 0.50
toStringMethod · 0.45

Tested by

no test coverage detected