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
Start moving to Uint8Array in new APIs? #41588
Comments
|
That will cause soo much confusion. I believe there are several methods/props that Buffer override and which act differently than Uint8Array. |
|
In particular |
|
I'm fine with using Uint8Array for Web apis which define the type. But for node api's I think we should stick with Buffer. |
|
It really depends on the subsystems we are targeting. It's impossible to make a generic call. |
|
I have a big problem with Buffers. They must be killed.
// Somewhere in your code
const privateBuf = Buffer.from(privateKey, 'hex');
// Rogue package can access
Buffer.from('1').buffer
// Which will of course show the contents of `privateBuf`
// No need in complex memory dumps!This happens because there is 8KB shared buffer reused for all |
|
Hey @paulmillr can we avoid statements like "they must be killed"? it detracts from technical arguments you are making and anyone with a strong opinion the other way will automatically be put on a defensive rather than be in a learning mood. (I'm going to read the rest of it just wanted to start with that quickly before others read it) |
FWIW: I agree having an API that behaves like a subclass but "lies" about keeping the same API structure is super-confusing. |
There was a suggestion by @jasnell to use
Uint8Arrays in new APIs overBuffers as well as a weigh-in by @sindresorhus saying it is easier to author cross-platform APIs when usingUint8Arrays.Here is a context #41553 (comment)
That is, the ask here is that Node.js should prefer
Uint8Arrays overBuffers in new APIs.What does everyone think? Should we stick to
Buffer(which is a subclass ofUint8Arrayas a reminder) or preferUint8Arrays over buffers when possible in new APIs?cc @nodejs/buffer @nodejs/streams
The text was updated successfully, but these errors were encountered: