/* global IEBinaryToArray_ByteStr, IEBinaryToArray_ByteStr_Last */ "use strict"; // Adapted from http://stackoverflow.com/questions/1095102/how-do-i-load-binary-image-data-using-javascript-and-xmlhttprequest const IEBinaryToArray_ByteStr_Script = "\r\n" + "\r\n"; // inject VBScript document.write(IEBinaryToArray_ByteStr_Script); global.PizZipUtils._getBinaryFromXHR = function (xhr) { const binary = xhr.responseBody; const byteMapping = {}; for (let i = 0; i < 256; i++) { for (let j = 0; j < 256; j++) { byteMapping[String.fromCharCode(i + (j << 8))] = String.fromCharCode(i) + String.fromCharCode(j); } } const rawBytes = IEBinaryToArray_ByteStr(binary); const lastChr = IEBinaryToArray_ByteStr_Last(binary); return ( rawBytes.replace(/[\s\S]/g, function (match) { return byteMapping[match]; }) + lastChr ); };