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

Method _write

lib/internal/vfs/streams.js:297–313  ·  view source on GitHub ↗

* Implements the writable _write method. * @param {Buffer|string} chunk Data to write * @param {string} encoding Encoding * @param {Function} callback Callback

(chunk, encoding, callback)

Source from the content-addressed store, hash-verified

295 * @param {Function} callback Callback
296 */
297 _write(chunk, encoding, callback) {
298 if (this.destroyed || this.#fd === null) {
299 callback(createEBADF('write'));
300 return;
301 }
302
303 try {
304 const buffer = typeof chunk === 'string' ?
305 Buffer.from(chunk, encoding) : chunk;
306 this.#vfs.writeSync(this.#fd, buffer, 0, buffer.length, null);
307 this.bytesWritten += buffer.length;
308 this.pending = false;
309 callback();
310 } catch (err) {
311 callback(err);
312 }
313 }
314
315 /**
316 * Implements the writable _final method (flush before close).

Callers

nothing calls this directly

Calls 4

createEBADFFunction · 0.85
callbackFunction · 0.50
fromMethod · 0.45
writeSyncMethod · 0.45

Tested by

no test coverage detected