Skip to content

Instantly share code, notes, and snippets.

@barnjamin
Created April 24, 2021 12:36
Show Gist options
  • Save barnjamin/59a483ef90b8e5c49be88f0cbafe1b72 to your computer and use it in GitHub Desktop.
Save barnjamin/59a483ef90b8e5c49be88f0cbafe1b72 to your computer and use it in GitHub Desktop.
function download_txns(name, txns) {
let b = new Uint8Array(0);
for(const txn in txns){
b = concatTypedArrays(b, txns[txn])
}
var blob = new Blob([b], {type: "application/octet-stream"});
var link = document.createElement('a');
link.href = window.URL.createObjectURL(blob);
link.download = name;
link.click();
}
function concatTypedArrays(a, b) {
var c = new (a.constructor)(a.length + b.length);
c.set(a, 0);
c.set(b, a.length);
return c;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment