Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fixup! doc: clarify array args to Buffer.from()
  • Loading branch information
bengl committed Jun 1, 2023
commit 48769eca32dda58a3cecddcf1160246d4a671a51
10 changes: 5 additions & 5 deletions doc/api/buffer.md
Original file line number Diff line number Diff line change
Expand Up @@ -1118,11 +1118,11 @@ const { Buffer } = require('node:buffer');
const buf = Buffer.from([0x62, 0x75, 0x66, 0x66, 0x65, 0x72]);
```

Note that if `array` is an `Array`-like object (that is, one with a `length`
property of type `number`) it is treated as if it is an array, unless it is a
`Buffer` or a `Uint8Array`. This means all other `TypedArray` variants get
treated as `Array`. To create a `Buffer` from the underlying `ArrayBuffer`, use
the `.buffer` property directly.
If `array` is an `Array`-like object (that is, one with a `length` property of
type `number`), it is treated as if it is an array, unless it is a `Buffer` or a
`Uint8Array`. This means all other `TypedArray` variants get treated as an
`Array`. To create a `Buffer` from the underlying `ArrayBuffer`, use the
`.buffer` property directly.

A `TypeError` will be thrown if `array` is not an `Array` or another type
appropriate for `Buffer.from()` variants.
Expand Down