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

Function runPull

benchmark/fs/bench-filehandle-pull-vs-webstream.js:176–201  ·  view source on GitHub ↗
(compressFactory)

Source from the content-addressed store, hash-verified

174}
175
176async function runPull(compressFactory) {
177 const fh = await fs.promises.open(filename, 'r');
178 try {
179 // Stateless transform: uppercase each chunk in the batch
180 const upper = (chunks) => {
181 if (chunks === null) return null;
182 const out = new Array(chunks.length);
183 for (let j = 0; j < chunks.length; j++) {
184 out[j] = uppercaseChunk(chunks[j]);
185 }
186 return out;
187 };
188
189 const readable = fh.pull(upper, compressFactory());
190
191 let totalBytes = 0;
192 for await (const chunks of readable) {
193 for (let i = 0; i < chunks.length; i++) {
194 totalBytes += chunks[i].byteLength;
195 }
196 }
197 return totalBytes;
198 } finally {
199 await fh.close();
200 }
201}

Callers 1

benchPullFunction · 0.85

Calls 3

openMethod · 0.65
closeMethod · 0.65
pullMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…