Skip to content

Commit 2991e7c

Browse files
tsabolovcodebytere
authored andcommitted
doc: correct getting an ArrayBuffer's length
`ArrayBuffer` instances do not have `.length` property. Instead they have `.byteLength` property. Fixed that in the description of `new Buffer(arrayBuffer[, byteOffset[, length]])` and `Buffer.from(arrayBuffer[, byteOffset[, length]])`. PR-URL: #31632 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 13c256d commit 2991e7c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

doc/api/buffer.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ changes:
384384
[`SharedArrayBuffer`][] or the `.buffer` property of a [`TypedArray`][].
385385
* `byteOffset` {integer} Index of first byte to expose. **Default:** `0`.
386386
* `length` {integer} Number of bytes to expose.
387-
**Default:** `arrayBuffer.length - byteOffset`.
387+
**Default:** `arrayBuffer.byteLength - byteOffset`.
388388

389389
This creates a view of the [`ArrayBuffer`][] or [`SharedArrayBuffer`][] without
390390
copying the underlying memory. For example, when passed a reference to the
@@ -830,7 +830,7 @@ added: v5.10.0
830830
[`SharedArrayBuffer`][], or the `.buffer` property of a [`TypedArray`][].
831831
* `byteOffset` {integer} Index of first byte to expose. **Default:** `0`.
832832
* `length` {integer} Number of bytes to expose.
833-
**Default:** `arrayBuffer.length - byteOffset`.
833+
**Default:** `arrayBuffer.byteLength - byteOffset`.
834834

835835
This creates a view of the [`ArrayBuffer`][] without copying the underlying
836836
memory. For example, when passed a reference to the `.buffer` property of a

0 commit comments

Comments
 (0)