blob-dl
Version:
A simple library to download a Blob from the browser as a file.
18 lines (17 loc) • 372 B
JavaScript
// src/index.ts
function downloadBlob(blob, name) {
let a = document.createElement("a");
a.href = URL.createObjectURL(blob);
a.download = name;
a.rel = "noopener";
a.style = "display: none";
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
setTimeout(() => {
URL.revokeObjectURL(a.href);
}, 3e4);
}
export {
downloadBlob
};