diff --git a/doc/api/buffer.md b/doc/api/buffer.md index 5c565724573434..50f24f1c12a543 100644 --- a/doc/api/buffer.md +++ b/doc/api/buffer.md @@ -2308,6 +2308,7 @@ added: v0.1.90 * {integer} Returns the number of bytes in `buf`. +An alias of the inherited [`buf.byteLength`][]. ```mjs import { Buffer } from 'buffer'; @@ -5240,6 +5241,7 @@ introducing security vulnerabilities into an application. [`TypedArray`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray [`Uint8Array`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array [`buf.buffer`]: #bufbuffer +[`buf.byteLength`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/byteLength [`buf.compare()`]: #bufcomparetarget-targetstart-targetend-sourcestart-sourceend [`buf.entries()`]: #bufentries [`buf.fill()`]: #buffillvalue-offset-end-encoding diff --git a/doc/api/fs.md b/doc/api/fs.md index cea4f600ac8bd0..569f91a46a6af6 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -378,7 +378,7 @@ added: * `offset` {integer} The location in the buffer at which to start filling. **Default:** `0` * `length` {integer} The number of bytes to read. **Default:** - `buffer.byteLength` + `buffer.length` (`.byteLength` for TypedArray|DataView types) * `position` {integer} The location where to begin reading data from the file. If `null`, data will be read from the current file position, and the position will be updated. If `position` is an integer, the current @@ -568,7 +568,8 @@ changes: * `offset` {integer} The start position from within `buffer` where the data to write begins. **Default:** `0` * `length` {integer} The number of bytes from `buffer` to write. **Default:** - `buffer.byteLength` + `buffer.length` (`.byteLength` for TypedArray|DataView types; + ignored for string|Object types) * `position` {integer} The offset from the beginning of the file where the data from `buffer` should be written. If `position` is not a `number`, the data will be written at the current position. See the POSIX pwrite(2) @@ -3022,7 +3023,7 @@ changes: * `options` {Object} * `buffer` {Buffer|TypedArray|DataView} **Default:** `Buffer.alloc(16384)` * `offset` {integer} **Default:** `0` - * `length` {integer} **Default:** `buffer.byteLength` + * `length` {integer} **Default:** `buffer.length` (`.byteLength` for TypedArray|DataView types) * `position` {integer|bigint} **Default:** `null` * `callback` {Function} * `err` {Error} @@ -4134,7 +4135,7 @@ the current position. See pwrite(2). The callback will receive the arguments `(err, written, string)` where `written` specifies how many _bytes_ the passed string required to be written. Bytes written is not necessarily the same as string characters written. See -[`Buffer.byteLength`][]. +[`Buffer.byteLength()`][]. It is unsafe to use `fs.write()` multiple times on the same file without waiting for the callback. For this scenario, [`fs.createWriteStream()`][] is @@ -5025,7 +5026,7 @@ changes: * `buffer` {Buffer|TypedArray|DataView} * `options` {Object} * `offset` {integer} **Default:** `0` - * `length` {integer} **Default:** `buffer.byteLength` + * `length` {integer} **Default:** `buffer.length` (`.byteLength` for TypedArray|DataView types) * `position` {integer|bigint} **Default:** `null` * Returns: {number} @@ -7025,7 +7026,7 @@ the file contents. [MSDN-Using-Streams]: https://docs.microsoft.com/en-us/windows/desktop/FileIO/using-streams [Naming Files, Paths, and Namespaces]: https://docs.microsoft.com/en-us/windows/desktop/FileIO/naming-a-file [`AHAFS`]: https://developer.ibm.com/articles/au-aix_event_infrastructure/ -[`Buffer.byteLength`]: buffer.md#static-method-bufferbytelengthstring-encoding +[`Buffer.byteLength()`]: buffer.md#static-method-bufferbytelengthstring-encoding [`FSEvents`]: https://developer.apple.com/documentation/coreservices/file_system_events [`Number.MAX_SAFE_INTEGER`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER [`ReadDirectoryChangesW`]: https://docs.microsoft.com/en-us/windows/desktop/api/winbase/nf-winbase-readdirectorychangesw