bitburner-src/src/utils/FileUtils.ts
catloversg 7b993f3550
MISC: Remove file-saver (#1217)
Also refactor to dedup our own download code
2024-04-19 13:38:44 -07:00

12 lines
371 B
TypeScript

export function downloadContentAsFile(content: BlobPart, filename: string): void {
const blob = new Blob([content]);
const anchorElement = document.createElement("a");
const url = URL.createObjectURL(blob);
anchorElement.href = url;
anchorElement.download = filename;
anchorElement.click();
setTimeout(function () {
URL.revokeObjectURL(url);
}, 0);
}