Skip to content

Instantly share code, notes, and snippets.

@stctheproducer
Last active December 2, 2021 16:23
Show Gist options
  • Save stctheproducer/99ee00da805674ddad83f41c45845d42 to your computer and use it in GitHub Desktop.
Save stctheproducer/99ee00da805674ddad83f41c45845d42 to your computer and use it in GitHub Desktop.
A TypeScript function to convert an array buffer to a binary string
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