UNPKG

igniteui-react-core

Version:
90 lines (89 loc) 3.43 kB
/* THIS INFRAGISTICS ULTIMATE SOFTWARE LICENSE AGREEMENT ("AGREEMENT") LOCATED HERE: https://www.infragistics.com/legal/license/igultimate-la https://www.infragistics.com/legal/license/igultimate-eula GOVERNS THE LICENSING, INSTALLATION AND USE OF INFRAGISTICS SOFTWARE. BY DOWNLOADING AND/OR INSTALLING AND USING INFRAGISTICS SOFTWARE: you are indicating that you have read and understand this Agreement, and agree to be legally bound by it on behalf of the yourself and your company. */ var BinaryUtil = /** @class */ /*@__PURE__*/ (function () { function BinaryUtil() { } BinaryUtil.isResponseTypeSupported = function (responseType) { var xhr = null; try { xhr = new XMLHttpRequest(); xhr.open("GET", "/"); xhr.responseType = responseType; } catch (e) { return false; } if (xhr === null) { return false; } return xhr.responseType === responseType; }; BinaryUtil.getBinary = function (url, callback, error) { var data, ret, req, useVbArray = false, arrayBufferSupported = BinaryUtil.isResponseTypeSupported("arraybuffer") && typeof Uint8Array != "undefined"; if (typeof XMLHttpRequest == "undefined") { try { req = new window.ActiveXObject("Msxml2.XMLHTTP.6.0"); } catch (e) { } try { req = new window.ActiveXObject("Msxml2.XMLHTTP.3.0"); } catch (e) { } req = new window.ActiveXObject("Microsoft.XMLHTTP"); } else { req = new XMLHttpRequest(); } if (!arrayBufferSupported) { if (req.overrideMimeType) { req.overrideMimeType("text/plain; charset=x-user-defined"); } } if (typeof window.VBArray != "undefined") { useVbArray = true; } req.onreadystatechange = function () { if (req.readyState == 4) { var isFileSchemeDownload = false; if (req.status == 0) { isFileSchemeDownload = new URL(url).protocol == "file:" || new URL(url).protocol == "igfile:"; } if (req.status == 200 || isFileSchemeDownload) { if (arrayBufferSupported && typeof this.response != "undefined") { callback(new Uint8Array(this.response)); } else { if (useVbArray) { data = new window.VBArray(req.responseBody).toArray(); for (var i = 0; i < data.length; i++) { data[i] = String.fromCharCode(data[i]); } ret = data.join(""); callback(ret); } else { callback(req.responseText); } } } else { error(req.error); } } }; req.open("GET", url, true); if (arrayBufferSupported) { req.responseType = "arraybuffer"; } req.send(null); }; ; return BinaryUtil; }()); export { BinaryUtil };