Skip to content

Instantly share code, notes, and snippets.

@akirattii
Created July 14, 2016 12:00
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 akirattii/747287e26844e2b5278948c205374e4c to your computer and use it in GitHub Desktop.
Save akirattii/747287e26844e2b5278948c205374e4c to your computer and use it in GitHub Desktop.
From ArrayBuffer to String | From ArrayBuffer of html to DOM
// buf is ArrayBuffer
function ab2str(buf) {
return td.decode(new Uint8Array(buf));
}
function ab2dom(buf) {
let html = ab2str(buf);
let rootEl = document.createElement('html');
rootEl.innerHTML = html;
return rootEl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment