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

Function testPipeToSync

test/parallel/test-stream-iter-pipeto.js:8–22  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

6const { pipeTo, pipeToSync, from, fromSync } = require('stream/iter');
7
8async function testPipeToSync() {
9 const written = [];
10 const writer = {
11 writeSync(chunk) { written.push(chunk); return true; },
12 endSync() { return written.length; },
13 fail() {},
14 };
15
16 const totalBytes = pipeToSync(fromSync('pipe-data'), writer);
17 assert.strictEqual(totalBytes, 9); // 'pipe-data' = 9 UTF-8 bytes
18 assert.ok(written.length > 0);
19 const result = new TextDecoder().decode(
20 new Uint8Array(written.reduce((acc, c) => [...acc, ...c], [])));
21 assert.strictEqual(result, 'pipe-data');
22}
23
24async function testPipeTo() {
25 const written = [];

Callers 1

Calls 5

pipeToSyncFunction · 0.85
reduceMethod · 0.80
decodeMethod · 0.65
fromSyncFunction · 0.50
okMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…