-
-
Notifications
You must be signed in to change notification settings - Fork 34.2k
Description
What is the problem this feature will solve?
Buffer.from() has many different forms, including Buffer.from(arrayBuffer[, byteOffset[, length]]) and Buffer.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), thrown TypeErrors and empty buffers.
Creating Buffer from ArrayBufferView's data in userland is extremely error-prone because Buffer.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 only Buffer and Uint8Array but any ArrayBufferView or at least any TypedArray.
What alternatives have you considered?
Deprecation and removal of Buffer from core into userspace module, with prior porting all core APIs to native Uint8Array/TypedArray/ArrayBufferViews.