Skip to content

Instantly share code, notes, and snippets.

@dneprDroid
Created January 14, 2020 22:05
Show Gist options
  • Select an option

  • Save dneprDroid/5759338971fd095a50e839f7035b903b to your computer and use it in GitHub Desktop.

Select an option

Save dneprDroid/5759338971fd095a50e839f7035b903b to your computer and use it in GitHub Desktop.
Save text file JS
var sampleBytes = new Int8Array(4096*1000*100);
var saveByteArray = (function () {
var a = document.createElement("a");
document.body.appendChild(a);
a.style = "display: none";
return function (data, name) {
var blob = new Blob(data, {type: "octet/stream"}),
url = window.URL.createObjectURL(blob);
console.log("Blob URL: ", url);
a.href = url;
a.download = name;
a.click();
window.URL.revokeObjectURL(url);
};
}());
saveByteArray([sampleBytes], 'example2.txt');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment