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

Function testTapInPipeline

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

Source from the content-addressed store, hash-verified

58}
59
60async function testTapInPipeline() {
61 const { writer, readable } = push();
62 const seen = [];
63
64 const observer = tap(async (chunks) => {
65 if (chunks !== null) {
66 for (const chunk of chunks) {
67 seen.push(new TextDecoder().decode(chunk));
68 }
69 }
70 });
71
72 writer.write('hello');
73 writer.end();
74
75 // Use pull with tap as a transform
76 const result = pull(readable, observer);
77 const data = await text(result);
78
79 assert.strictEqual(data, 'hello');
80 assert.strictEqual(seen.length, 1);
81 assert.strictEqual(seen[0], 'hello');
82}
83
84// Tap callback error propagates through async pipeline
85async function testTapAsyncErrorPropagation() {

Calls 8

tapFunction · 0.85
pushFunction · 0.70
pullFunction · 0.70
decodeMethod · 0.65
textFunction · 0.50
pushMethod · 0.45
writeMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected