Created
June 30, 2019 18:50
-
-
Save kijart/d4fe564859835a05ad98dc466a1c27e7 to your computer and use it in GitHub Desktop.
This file contains 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 hex2binDownload(hex, fileName) { | |
const binary = hex.match(/[A-F0-9]{2}/g).map((value) => parseInt(value, 16)); | |
const byteArray = new Uint8Array(binary); | |
let a = window.document.createElement('a'); | |
a.href = window.URL.createObjectURL(new Blob([byteArray], { type: 'application/octet-stream' })); | |
a.download = fileName; | |
document.body.appendChild(a) | |
a.click(); | |
document.body.removeChild(a) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment