(data, fileName)
| 52013 | // Licensed under the MIT license. |
| 52014 | parcelHelpers.export(exports, "downloadData", ()=>downloadData); |
| 52015 | function downloadData(data, fileName) { |
| 52016 | // Adapted from https://ourcodeworld.com/articles/read/189/how-to-create-a-file-and-generate-a-download-with-javascript-in-the-browser-without-a-server |
| 52017 | var a = document.createElement("a"); |
| 52018 | a.setAttribute("download", fileName); |
| 52019 | document.body.appendChild(a); |
| 52020 | const blob = dataURIToBlob(data); |
| 52021 | a.href = URL.createObjectURL(blob); |
| 52022 | // we must revoke the object URL, |
| 52023 | // since we can't know when the download occured, we have to attach it on the click handler.. |
| 52024 | a.onclick = ()=>{ |
| 52025 | // ..and to wait a frame |
| 52026 | requestAnimationFrame(()=>URL.revokeObjectURL(a.href)); |
| 52027 | document.body.removeChild(a); |
| 52028 | }; |
| 52029 | a.click(); |
| 52030 | } |
| 52031 | //from https://stackoverflow.com/a/37151835/620501 |
| 52032 | function dataURIToBlob(binStr) { |
| 52033 | var len = binStr.length, arr = new Uint8Array(len); |
nothing calls this directly
no test coverage detected