News for hackers. Stuff that matters.
Re:Goodbye, Node.js Buffer by kev946 on Tuesday October 24, 2023 @10:14AM (#37999429)
I find buffer useful for its conversion functions to/from different encodings, e.g., `Buffer.from(data, 'hex')` or `Buffer.toString('base64')`. Is there a good way to do this with `Uint8Array`?
Re:Goodbye, Node.js Buffer by ash_gti on Tuesday October 24, 2023 @10:28AM (#37999640)
You can use ‘atob’ and ‘btoa’ functions for some of that.
Re:Goodbye, Node.js Buffer by denzquix on Tuesday October 24, 2023 @10:51AM (#37999978)
Although those functions operate on "binary strings", not Uint8Arrays, and there is no especially clean way that vanilla JS exposes to convert between the two that I am aware of.
Re:Goodbye, Node.js Buffer by esprehn on Tuesday October 24, 2023 @04:16PM (#38004836)
Those functions are fundamentally broken: https://developer.mozilla.org/en-US/docs/Glossary/Base64#jav...

See the whole section on converting arbitrary binary data and the complex ways to do it.

Re:Goodbye, Node.js Buffer by davidmurdoch on Tuesday October 24, 2023 @10:17AM (#37999478)
Polyfill Buffer.
Re:Goodbye, Node.js Buffer by norman784 on Tuesday October 24, 2023 @10:31AM (#37999682)
I would prefer not install any dependency if possible, I don't see a necessity of installing a polyfill just to not use the built in one because it's node specific.
Re:Goodbye, Node.js Buffer by mofle on Tuesday October 24, 2023 @10:46AM (#37999902)
People are working on bringing Base64/Hex conversion to JavaScript: https://github.com/tc39/proposal-arraybuffer-base64

I also provide a package to make the transition easier: https://github.com/sindresorhus/uint8array-extras (Feel free to copy-paste the code if you don't want another dependency)

Re:Goodbye, Node.js Buffer by bsimpson on Tuesday October 24, 2023 @08:28PM (#38007647)
Thanks for all the utility belts you've provided to the ecosystem.

It's insane to me that something as simple as concatenating an array needs a library, but as I've shown upthread, Uint8Arrays are way too complicated to work with.