Created
January 8, 2025 09:58
-
-
Save socheatsok78/d5df5c34cb3e05df2aca1193a1bebf20 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
/** | |
* A backward-compatible for FileReader: readAsBinaryString() method | |
* @param arrayBuffer {ArrayBuffer} | |
* @see https://developer.mozilla.org/en-US/docs/Web/API/FileReader/readAsBinaryString | |
*/ | |
function readAsBinaryString (arrayBuffer) { | |
const binary = [] | |
const arrayBufferView = new Uint8Array(arrayBuffer) | |
for (let i = 0; i < arrayBufferView.length; i++) { | |
binary.push(String.fromCharCode(arrayBufferView[i])) | |
} | |
return binary.join('') | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment