Skip to content

Instantly share code, notes, and snippets.

Last active October 30, 2022 19:55
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Download a file in JavaScript with Emscripten / WebAssembly.
function download(filenamePtr, dataPtr, size) {
const a = document.createElement('a') = 'display:none'
const view = new Uint8Array(Module.HEAPU8.buffer, dataPtr, size)
const blob = new Blob([view], {
type: 'octet/stream'
const url = window.URL.createObjectURL(blob)
a.href = url
const filename = UTF8ToString(filenamePtr) = filename
} = download
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment