Skip to content
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

ArrayBuffer <-> Buffer interop? #177

Closed
YurySolovyov opened this issue Dec 17, 2014 · 4 comments
Closed

ArrayBuffer <-> Buffer interop? #177

YurySolovyov opened this issue Dec 17, 2014 · 4 comments

Comments

@YurySolovyov
Copy link

Any updates on this?
If I remember correctly it had some performance problems, but v8 changed a lot since then.
It could be useful for "mixed" node environments such as node-webkit and atom-shell, where you have browser-side APIs that deals only with ArrayBuffer.

So request is to have symmetrical Buffer.toArrayBuffer() and Buffer.from(ArrayBuffer) API, or some other way to make one from the other.

@chrisdickinson
Copy link
Contributor

The discussion around that is currently going on over here, I do believe!

@feross
Copy link
Contributor

feross commented Jan 20, 2015

@YuriSolovyov You can convert an ArrayBuffer to a Buffer trivially (with a copy) like this: new Buffer(new Uint8Array(arrayBuffer))

There used to be a buffer.toArrayBuffer() method, but it was removed by @trevnorris because of a memory leak.

@vkurchatkin
Copy link
Contributor

@feross new Buffer(new Uint8Array(arrayBuffer)) is slow: https://github.com/iojs/io.js/blob/v1.x/lib/buffer.js#L91

@trevnorris
Copy link
Contributor

@vkurchatkin correct. it is slow. though the only way to "correctly" do it would be to Externalize the ArrayBuffer then do the memcpy. I'm fine experimenting with it, or entertaining a PR that does the same.

minervapanda added a commit to minervapanda/node that referenced this issue Oct 10, 2016
This decreases the font size in chatbox.xml.

Fixes nodejs#177.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants