-
Notifications
You must be signed in to change notification settings - Fork 29.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Buffer.from(<ArrayBufferView>
)
#43862
Comments
There has been no activity on this feature request for 5 months and it is unlikely to be implemented. It will be closed 6 months after the last non-automated comment. For more information on how the project manages feature requests, please consult the feature request management document. |
This should be kept open. It's still needed |
@jasnell Is this actionable, though? |
It doesn't need to be |
Yeah, we could do that. It’s probably worth thinking about the name – it should reflect that it creates the buffer from the underlying memory of a TypedArray rather than its contents – and it’s probably still worth thinking about whether this really makes sense to address in Node.js itself (the fact that writing |
Agreed with idea of separate method; its existence by itself would also imply that |
Fixes: #43862 PR-URL: #46500 Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
Fixes: #43862 PR-URL: #46500 Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
Fixes: #43862 PR-URL: #46500 Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
What is the problem this feature will solve?
Buffer.from()
has many different forms, includingBuffer.from(arrayBuffer[, byteOffset[, length]])
andBuffer.from(buffer)
.However,
Buffer.from(abv)
does not exist. Depending on exact input, trying to call it with such objects results in false positives, data truncation, data corruption (e.g.double
->unsigned char
), thrownTypeError
s and empty buffers.Creating
Buffer
fromArrayBufferView
's data in userland is extremely error-prone becauseBuffer.from(arrayBuffer)
doesn't copy the data.What is the feature you are proposing to solve the problem?
Adjust
Buffer.from(buffer)
to accept not onlyBuffer
andUint8Array
but anyArrayBufferView
or at least anyTypedArray
.What alternatives have you considered?
Deprecation and removal of
Buffer
from core into userspace module, with prior porting all core APIs to nativeUint8Array
/TypedArray
/ArrayBufferView
s.The text was updated successfully, but these errors were encountered: