Live data from Hacker News

Goodbye, Node.js Buffer

sindresorhus.com

1–10 of 103 posts

Re: Goodbye, Node.js Buffer

#2
I recently ran into an issue where I needed to store an Uint8Array as a BYTEA in postgres. When i stored it directly, the Uint8Array would be modified and made bigger. When i converted it to a buffer and then stored it, it would work. Still not sure why that was the case.

Re: Goodbye, Node.js Buffer

#3
It's good to see that people care about native JS standards. I'm a bit concerned how Bun seems to be adding their own proprietary APIs to their JS runtime, and can't help feeling that it could be intentional vendor lock-in. Since they are venture backed I'm sure they want some ROI from the project eventually and if they start charging money it will be harder to switch away due to the proprietary APIs without refactoring your project.

Re: Goodbye, Node.js Buffer

#4
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

#7
post #2

I recently ran into an issue where I needed to store an Uint8Array as a BYTEA in postgres. When i stored it directly, the Uint8Array would be modified and made bigger. When i converted it to a buffer and then stored it, it would work. Still not sure why that was the case.

I wonder if that's a lack of good support for Uint8Array in the client you're using with postgres?

Re: Goodbye, Node.js Buffer

#8
> Buffer also comes with additional caveats. For instance, Buffer#slice() creates a mutable segment linked to the original Buffer, while Uint8Array#slice() creates an immutable copy, resulting in possible unpredictable behavior.

I can see how the Buffer behavior here would be preferable in cases where performance is important or memory constrained environments.

Re: Goodbye, Node.js Buffer

#9
I've been using the native Uint8Array that Deno provides and it's been great overall. From time to time I may need to covert away from a Buffer type and it's a little bit of a headache, but I think the ecosystem is supporting Uint8Array, at least on the server very well.

Re: Goodbye, Node.js Buffer

#10
post #3

It's good to see that people care about native JS standards. I'm a bit concerned how Bun seems to be adding their own proprietary APIs to their JS runtime, and can't help feeling that it could be intentional vendor lock-in. Since they are venture backed I'm sure they want some ROI from the project eventually and if they start charging money it will be harder to switch away due to the proprietary APIs without refactor…

It's really because we have some wonderful collaboration between vendors now, and they don't want to have to come up with their own APIs.

https://wintercg.org/

Post reply on HN