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

Function testTapSync

test/parallel/test-stream-iter-consumers-tap.js:22–42  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

20// =============================================================================
21
22async function testTapSync() {
23 const observed = [];
24 const observer = tapSync((chunks) => {
25 if (chunks !== null) {
26 observed.push(chunks.length);
27 }
28 });
29
30 // tapSync returns a function transform
31 assert.strictEqual(typeof observer, 'function');
32
33 // Test that it passes data through unchanged
34 const input = [new Uint8Array([1]), new Uint8Array([2])];
35 const result = observer(input);
36 assert.deepStrictEqual(result, input);
37 assert.deepStrictEqual(observed, [2]);
38
39 // null (flush) passes through
40 const flushResult = observer(null);
41 assert.strictEqual(flushResult, null);
42}
43
44async function testTapAsync() {
45 const observed = [];

Calls 3

tapSyncFunction · 0.85
observerFunction · 0.85
pushMethod · 0.45

Tested by

no test coverage detected