@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
18 lines (17 loc) • 641 B
JavaScript
;
export function createObjectURL(fileOrBlob) {
const urlCreator = globalThis.URL || globalThis.webkitURL;
return urlCreator.createObjectURL(fileOrBlob);
}
export function downloadBlob(blob, fileName) {
const urlCreator = globalThis.URL || globalThis.webkitURL;
const blobUrl = urlCreator.createObjectURL(blob);
const element = document.createElement("a");
element.setAttribute("href", blobUrl);
element.setAttribute("target", "_blank");
element.setAttribute("download", fileName);
element.style.display = "none";
document.body.appendChild(element);
element.click();
document.body.removeChild(element);
}