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

Function write

lib/internal/fs/promises.js:881–909  ·  view source on GitHub ↗
(chunk, options = kNullPrototo)

Source from the content-addressed store, hash-verified

879 return {
880 __proto__: null,
881 write(chunk, options = kNullPrototo) {
882 if (error) {
883 return PromiseReject(error);
884 }
885 if (closed) {
886 return PromiseReject(
887 new ERR_INVALID_STATE.TypeError('The writer is closed'));
888 }
889 validateObject(options, 'options');
890 const {
891 signal,
892 } = options;
893 if (signal !== undefined) {
894 validateAbortSignal(signal, 'options.signal');
895 if (signal.aborted) {
896 return PromiseReject(signal.reason);
897 }
898 }
899 chunk = newStreamsToUint8Array(chunk);
900 if (bytesRemaining >= 0 && chunk.byteLength > bytesRemaining) {
901 return PromiseReject(
902 new ERR_OUT_OF_RANGE('write', `<= ${bytesRemaining} bytes`,
903 chunk.byteLength));
904 }
905 if (bytesRemaining > 0) bytesRemaining -= chunk.byteLength;
906 const position = pos;
907 if (pos >= 0) pos += chunk.byteLength;
908 return writeAll(chunk, 0, chunk.byteLength, position, signal);
909 },
910
911 writev(chunks, options = kNullPrototo) {
912 if (error) {

Callers 1

writeFileHandleFunction · 0.70

Calls 2

validateAbortSignalFunction · 0.85
writeAllFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…