Last active
December 2, 2021 16:23
-
-
Save stctheproducer/99ee00da805674ddad83f41c45845d42 to your computer and use it in GitHub Desktop.
A TypeScript function to convert an array buffer to a binary string
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
const arrayBufferToString = (arrayBuffer: ArrayBuffer): string => { | |
let binary = '' | |
const bytes = new Uint8Array(arrayBuffer) | |
const len = bytes.byteLength | |
for (var i = 0; i < len; i++) { | |
binary += String.fromCharCode(bytes[i]) | |
} | |
return binary | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment