Skip to content

ArrayBuffer <-> Buffer interop? #177

Description

@YurySolovyov

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.

Activity

  1. chrisdickinson commented on Dec 17, 2014

    @chrisdickinson
    Contributor

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

  2. feross commented on Jan 20, 2015

    @feross
    Contributor

    @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.

  3. vkurchatkin commented on Jan 20, 2015

    @vkurchatkin
    Contributor

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

  4. trevnorris commented on Jan 21, 2015

    @trevnorris
    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.

  5. added a commit that references this issue on Oct 10, 2016
    18e839f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions