Skip to content

Instantly share code, notes, and snippets.

@nuclearglow
Created January 26, 2018 10:30
Show Gist options
  • Save nuclearglow/ab251744db0ebddd504eea28153eb279 to your computer and use it in GitHub Desktop.
Save nuclearglow/ab251744db0ebddd504eea28153eb279 to your computer and use it in GitHub Desktop.
ArrayBuffer <-> JSON <-> ArrayBuffer
// array buffer to JSON
const dataString JSON.stringify(Array.from(new Uint8Array(arrayBuffer)));
// send around
// JSON to ArrayBuffer
new Uint8Array(JSON.parse(dataString)).buffer
@WillTechX20
Copy link

This was extremely helpful to me! This is truly an outstanding answer! Thank you, nuclearglow - you're a lifesaver!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment