-
-
Notifications
You must be signed in to change notification settings - Fork 37.1k
Buffer.from(<ArrayBufferView>) #43862
Copy link
Copy link
Closed
Labels
bufferIssues and PRs related to the buffer subsystem.Issues and PRs related to the buffer subsystem.feature requestIssues requesting new Node.js features.Issues requesting new Node.js features.never-staleIssues and PRs exempt from automated stale handling.Issues and PRs exempt from automated stale handling.
Description
Activity
Metadata
Metadata
Assignees
Labels
bufferIssues and PRs related to the buffer subsystem.Issues and PRs related to the buffer subsystem.feature requestIssues requesting new Node.js features.Issues requesting new Node.js features.never-staleIssues and PRs exempt from automated stale handling.Issues and PRs exempt from automated stale handling.
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), thrownTypeErrors and empty buffers.Creating
BufferfromArrayBufferView'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 onlyBufferandUint8Arraybut anyArrayBufferViewor at least anyTypedArray.What alternatives have you considered?
Deprecation and removal of
Bufferfrom core into userspace module, with prior porting all core APIs to nativeUint8Array/TypedArray/ArrayBufferViews.