Convert nodejs' Buffer to browsers' javascript

There is no direct support for Buffer in browser-based JavaScript, and I am not aware of any compatibility library that implements the Buffer API (yet).

The equivalent functionality in the browser is provided by TypedArrays. You can learn about them here:

  • https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays

When porting a Node Buffer-based implementation to browser-based JavaScript, I found these answers helpful:

  • Converting between strings and ArrayBuffers
  • Javascript - Converting between Unicode string and ArrayBuffer

With https://github.com/substack/node-browserify you can work with buffers in the Browser by using: https://github.com/toots/buffer-browserify. However: this can be very slow in the browser: For faster access use https://github.com/chrisdickinson/bops