Skip to content
This repository has been archived by the owner on Jun 2, 2022. It is now read-only.

Use TypedArrays instead of Node.js Buffers #3

Open
vmx opened this issue Sep 18, 2019 · 2 comments
Open

Use TypedArrays instead of Node.js Buffers #3

vmx opened this issue Sep 18, 2019 · 2 comments

Comments

@vmx
Copy link
Member

vmx commented Sep 18, 2019

I think we should build or JS libraries (especially new ones) with Browser primitives and not Node.js ones. Hence I suggest using TypedArrays instead of Node.js Buffers.

I know that's a bigger issue and there were already lengthy discussions about it. So if this isn't the right place for the issue, feel free to open a new one/link to another one.

I just fear that if we don't start using TypedArrays rather soon, Node.js Buffers will bleed up to all the other stuff we build on top and we will never change it.

@mikeal
Copy link
Contributor

mikeal commented Sep 18, 2019

I agree, which is why I wrote https://github.com/mikeal/bytesish but when I was writing the latest PR here I realized that I don’t expose the faster allocUnsafe call so I’m going to need to improve it before I can use it in my most recent PR.

But yes, I think this is where we should push in general. In fact, there’s some fundamental changes we should make to get-codec and how this library uses it in order to trim the bundle size as well.

@mikeal
Copy link
Contributor

mikeal commented Sep 18, 2019

Oh, for the record, I think that we should avoid using Buffer directly but we should still return Buffer instances in Node.js. This is easily doable with bytesish.native() but is a little different than “using typearrays instead of Node.js Buffers.”

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants