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

Function testConsumersNonArrayBatch

test/parallel/test-stream-iter-consumers-bytes.js:137–164  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

135// Regression test: consumers should tolerate sources that yield raw
136// Uint8Array or string values instead of Uint8Array[] batches.
137async function testConsumersNonArrayBatch() {
138 const encoder = new TextEncoder();
139
140 // Source yields raw Uint8Array, not wrapped in an array
141 async function* rawSource() {
142 yield encoder.encode('hello');
143 yield encoder.encode(' world');
144 }
145 const result = await text(rawSource());
146 assert.strictEqual(result, 'hello world');
147
148 // bytes() with raw chunks
149 async function* rawSource2() {
150 yield encoder.encode('ab');
151 }
152 const data = await bytes(rawSource2());
153 assert.strictEqual(data.length, 2);
154 assert.strictEqual(data[0], 97); // 'a'
155 assert.strictEqual(data[1], 98); // 'b'
156
157 // array() with raw chunks
158 async function* rawSource3() {
159 yield encoder.encode('x');
160 yield encoder.encode('y');
161 }
162 const arr = await array(rawSource3());
163 assert.strictEqual(arr.length, 2);
164}
165
166async function testConsumersNonArrayBatchSync() {
167 const encoder = new TextEncoder();

Calls 6

rawSourceFunction · 0.85
rawSource2Function · 0.85
rawSource3Function · 0.85
textFunction · 0.50
bytesFunction · 0.50
arrayFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…