Created
July 25, 2022 10:46
-
-
Save semlinker/ea97dab1497e8d6f48c7ab67d9c53f04 to your computer and use it in GitHub Desktop.
Save File
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function saveAs({ name, buffers, mime = "application/octet-stream" }) { | |
const blob = new Blob([buffers], { type: mime }); | |
const blobUrl = URL.createObjectURL(blob); | |
const a = document.createElement("a"); | |
a.download = name || Math.random(); | |
a.href = blobUrl; | |
a.click(); | |
URL.revokeObjectURL(blob); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment