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

Method writev

lib/internal/vfs/file_handle.js:294–305  ·  view source on GitHub ↗

* Writes data from multiple buffers to the file. * @param {Buffer[]} buffers The buffers to write from * @param {number|null} [position] The position to write to * @returns {Promise<{ bytesWritten: number, buffers: Buffer[] }>}

(buffers, position)

Source from the content-addressed store, hash-verified

292 * @returns {Promise<{ bytesWritten: number, buffers: Buffer[] }>}
293 */
294 async writev(buffers, position) {
295 this.#checkClosed('writev');
296 let totalWritten = 0;
297 for (let i = 0; i < buffers.length; i++) {
298 const buf = buffers[i];
299 const pos = position != null ? position + totalWritten : null;
300 const { bytesWritten } = await this.write(buf, 0, buf.byteLength, pos);
301 totalWritten += bytesWritten;
302 if (bytesWritten < buf.byteLength) break;
303 }
304 return { __proto__: null, bytesWritten: totalWritten, buffers };
305 }
306
307 /**
308 * Appends data to the file.

Callers

nothing calls this directly

Calls 2

#checkClosedMethod · 0.95
writeMethod · 0.95

Tested by

no test coverage detected