Closed as not planned
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.