Skip to content

Instantly share code, notes, and snippets.

@canimus
Created December 20, 2019 16:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save canimus/ee709979af82c2cf1623fc51af7e5aef to your computer and use it in GitHub Desktop.
Save canimus/ee709979af82c2cf1623fc51af7e5aef to your computer and use it in GitHub Desktop.
msgpack javascript example
function readFile(stream) {
return new Promise((resolve, reject) => {
var fr = new FileReader();
fr.onload = () => {
resolve(msgpack.decode(new Uint8Array(fr.result)))
};
fr.readAsArrayBuffer(stream);
});
}
fetch("/static/m1.msgpack")
.then(r => r.blob())
.then(readFile)
.then(console.log)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment