-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
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 that request new features to be added to Node.js.Issues that request new features to be added to Node.js.never-staleMark issue so that it is never considered staleMark issue so that it is never considered stale
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.never-staleMark issue so that it is never considered staleMark issue so that it is never considered stale
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.