-
-
Notifications
You must be signed in to change notification settings - Fork 32.6k
Closed as not planned
Labels
bufferIssues and PRs related to the buffer subsystem.Issues and PRs related to the buffer subsystem.feature requestIssues that request new features to be added to Node.js.Issues that request new features to be added to Node.js.stale
Description
The issue
The Buffer.copyBytesFrom
method was added by the issue #43862. What it does is create a Buffer
by copying the data to which the view of an ArrayBuffer
or SharedArrayBuffer
is referring (“viewing”). The current problem is that it only accepts a TypedArray
for its view
parameter, when DataView
s, too, are views.
> Buffer.copyBytesFrom(new DataView(new SharedArrayBuffer(1024)))
Uncaught:
TypeError [ERR_INVALID_ARG_TYPE]: The "view" argument must be an instance of TypedArray. Received an instance of DataView
at __node_internal_captureLargerStackTrace (node:internal/errors:490:5)
at new NodeError (node:internal/errors:399:5)
at Function.copyBytesFrom (node:buffer:347:11) {
code: 'ERR_INVALID_ARG_TYPE'
}
My suggestion
I suggest:
- enabling
Buffer.copyBytesFrom
to accept aDataView
as well for theview
parameter. - modifying the documentation accordingly.
introspection3
Metadata
Metadata
Assignees
Labels
bufferIssues and PRs related to the buffer subsystem.Issues and PRs related to the buffer subsystem.feature requestIssues that request new features to be added to Node.js.Issues that request new features to be added to Node.js.stale