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

Method readv

lib/internal/vfs/file_handle.js:275–286  ·  view source on GitHub ↗

* Reads data from the file into multiple buffers. * @param {Buffer[]} buffers The buffers to read into * @param {number|null} [position] The position to read from * @returns {Promise<{ bytesRead: number, buffers: Buffer[] }>}

(buffers, position)

Source from the content-addressed store, hash-verified

273 * @returns {Promise<{ bytesRead: number, buffers: Buffer[] }>}
274 */
275 async readv(buffers, position) {
276 this.#checkClosed('readv');
277 let totalRead = 0;
278 for (let i = 0; i < buffers.length; i++) {
279 const buf = buffers[i];
280 const pos = position != null ? position + totalRead : null;
281 const { bytesRead } = await this.read(buf, 0, buf.byteLength, pos);
282 totalRead += bytesRead;
283 if (bytesRead < buf.byteLength) break;
284 }
285 return { __proto__: null, bytesRead: totalRead, buffers };
286 }
287
288 /**
289 * Writes data from multiple buffers to the file.

Callers

nothing calls this directly

Calls 2

#checkClosedMethod · 0.95
readMethod · 0.95

Tested by

no test coverage detected