GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — doc: clarify array args to Buffer.from() · nodejs/node@2c19f59

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • doc/api
    • buffer.md
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎doc/api/buffer.md‎

Copy file name to clipboardExpand all lines: doc/api/buffer.md
+7Lines changed: 7 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -1116,6 +1116,12 @@ const { Buffer } = require('node:buffer');
11161116
const buf = Buffer.from([0x62, 0x75, 0x66, 0x66, 0x65, 0x72]);
11171117
```
11181118

1119+
If `array` is an `Array`-like object (that is, one with a `length` property of
1120+
type `number`), it is treated as if it is an array, unless it is a `Buffer` or
1121+
a `Uint8Array`. This means all other `TypedArray` variants get treated as an
1122+
`Array`. To create a `Buffer` from the bytes backing a `TypedArray`, use
1123+
[`Buffer.copyBytesFrom()`][].
1124+
11191125
A `TypeError` will be thrown if `array` is not an `Array` or another type
11201126
appropriate for `Buffer.from()` variants.
11211127

@@ -5488,6 +5494,7 @@ introducing security vulnerabilities into an application.
54885494
[`Buffer.allocUnsafe()`]: #static-method-bufferallocunsafesize
54895495
[`Buffer.allocUnsafeSlow()`]: #static-method-bufferallocunsafeslowsize
54905496
[`Buffer.concat()`]: #static-method-bufferconcatlist-totallength
5497+
[`Buffer.copyBytesFrom()`]: #static-method-buffercopybytesfromview-offset-length
54915498
[`Buffer.from(array)`]: #static-method-bufferfromarray
54925499
[`Buffer.from(arrayBuf)`]: #static-method-bufferfromarraybuffer-byteoffset-length
54935500
[`Buffer.from(buffer)`]: #static-method-bufferfrombuffer

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.