ArrayBuffer.js 412 Bytes
Newer Older
1 2 3 4
// shameless copy from
// https://stackoverflow.com/a/9458996
// This is because base64-codec/Data.Base64.encodeBase64 was too slow

5 6 7 8 9 10 11 12 13
exports.arrayBufferToBase64Impl = function(buffer) {
    var binary = '';
    var bytes = new Uint8Array( buffer );
    var len = bytes.byteLength;
    for (var i = 0; i < len; i++) {
        binary += String.fromCharCode( bytes[ i ] );
    }
    return window.btoa( binary );
}