Skip to content

Instantly share code, notes, and snippets.

@corocoto
Last active January 30, 2021 10:42
Show Gist options
  • Save corocoto/2f2532ed61abf96076c416c03b7c691e to your computer and use it in GitHub Desktop.
Save corocoto/2f2532ed61abf96076c416c03b7c691e to your computer and use it in GitHub Desktop.
Creaing URL that display various ASCII codes (created by TypedArray)
function typedArrayToURL(typedArr, mimeType) {
return URL.createObjectURL(new Blob([typedArr.buffer], {type: mimeType}));
}
const bytes = new Uint8Array(59); // you can change this value and calculating bellow for dispalying another/additional ASCII codes
for(let i = 0; i < 59; i++) {
bytes[i] = 32 + i;
}
const url = typedArrayToURL(bytes, 'text/plain');
const a = document.createElement('a');
a.href = url;
a.textContent = 'ASCII codes created by TypedArray';
document.body.appendChild(a);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment