Created
July 14, 2016 12:00
-
-
Save akirattii/747287e26844e2b5278948c205374e4c to your computer and use it in GitHub Desktop.
From ArrayBuffer to String | From ArrayBuffer of html to DOM
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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