vendor: 4,120 bytes, lines 1-87
1/*@preserve 2JSZipUtils - A collection of cross-browser utilities to go along with JSZip. 3<http://stuk.github.io/jszip-utils> 4(c) 2014-2019 Stuart Knightley, David Duponchel 5Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip-utils/master/LICENSE.markdown. 6*/ 7!function(e){"object"==typeof exports?module.exports=e():"function"==typeof define&&define.amd?define(e):"undefined"!=typeof window?window.JSZipUtils=e():"undefined"!=typeof global?global.JSZipUtils=e():"undefined"!=typeof self&&(self.JSZipUtils=e())}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ 8 'use strict'; 9 /*globals Promise */ 10 11 var JSZipUtils = {}; 12 // just use the responseText with xhr1, response with xhr2. 13 // The transformation doesn't throw away high-order byte (with responseText) 14 // because JSZip handles that case. If not used with JSZip, you may need to 15 // do it, see https://developer.mozilla.org/En/Using_XMLHttpRequest#Handling_binary_data 16 JSZipUtils._getBinaryFromXHR = function (xhr) { 17 // for xhr.responseText, the 0xFF mask is applied by JSZip 18 return xhr.response || xhr.responseText; 19 }; 20 21 // taken from jQuery 22 function createStandardXHR() { 23 try { 24 return new window.XMLHttpRequest(); 25 } catch( e ) {} 26 } 27 28 function createActiveXHR() { 29 try { 30 return new window.ActiveXObject("Microsoft.XMLHTTP"); 31 } catch( e ) {} 32 } 33 34 // Create the request object 35 var createXHR = (typeof window !== "undefined" && window.ActiveXObject) ? 36 /* Microsoft failed to properly 37 * implement the XMLHttpRequest in IE7 (can't request local files), 38 * so we use the ActiveXObject when it is available 39 * Additionally XMLHttpRequest can be disabled in IE7/IE8 so 40 * we need a fallback. 41 */ 42 function() { 43 return createStandardXHR() || createActiveXHR(); 44 } : 45 // For all other browsers, use the standard XMLHttpRequest object 46 createStandardXHR; 47 48 49 /** 50 * @param {string} path The path to the resource to GET. 51 * @param {function|{callback: function, progress: function}} options 52 * @return {Promise|undefined} If no callback is passed then a promise is returned 53 */ 54 JSZipUtils.getBinaryContent = function (path, options) { 55 var promise, resolve, reject; 56 var callback; 57 58 if (!options) { 59 options = {}; 60 } 61 62 // backward compatible callback 63 if (typeof options === "function") { 64 callback = options; 65 options = {}; 66 } else if (typeof options.callback === 'function') { 67 // callback inside options object 68 callback = options.callback; 69 } 70 71 if (!callback && typeof Promise !== "undefined") { 72 promise = new Promise(function (_resolve, _reject) { 73 resolve = _resolve; 74 reject = _reject; 75 }); 76 } else { 77 resolve = function (data) { callback(null, data); }; 78 reject = function (err) { callback(err, null); }; 79 } 80 81 /* 82 * Here is the tricky part : getting the data. 83 * In firefox/chrome/opera/... setting the mimeType to 'text/plain; charset=x-user-defined' 84 * is enough, the result is in the standard xhr.responseText. 85 * cf https://developer.mozilla.org/En/XMLHttpRequest/Using_XMLHttpRequest#Receiving_binary_data_in_older_browsers 86 * In IE <= 9, we must use (the IE only) attribute responseBody 87 * (for binary data, its content is different from responseText).
88 * In IE 10, the 'charset=x-user-defined' trick doesn't work, only the 89 * responseType will work : 90 * http://msdn.microsoft.com/en-us/library/ie/hh673569%28v=vs.85%29.aspx#Binary_Object_upload_and_download 91 * 92 * I'd like to use jQuery to avoid this XHR madness, but it doesn't support 93 * the responseType attribute : http://bugs.jquery.com/ticket/11461 94 */ 95 try { 96 var xhr = createXHR(); 97 98 xhr.open('GET', path, true); 99 100 // recent browsers 101 if ("responseType" in xhr) { 102 xhr.responseType = "arraybuffer"; 103 } 104 105 // older browser 106 if(xhr.overrideMimeType) { 107 xhr.overrideMimeType("text/plain; charset=x-user-defined"); 108 } 109 110 xhr.onreadystatechange = function (event) { 111 // use `xhr` and not `this`... thanks IE 112 if (xhr.readyState === 4) { 113 if (xhr.status === 200 || xhr.status === 0) { 114 try { 115 resolve(JSZipUtils._getBinaryFromXHR(xhr)); 116 } catch(err) { 117 reject(new Error(err)); 118 } 119 } else { 120 reject(new Error("Ajax error for " + path + " : " + this.status + " " + this.statusText)); 121 } 122 } 123 }; 124 125 if(options.progress) { 126 xhr.onprogress = function(e) { 127 options.progress({ 128 path: path, 129 originalEvent: e, 130 percent: e.loaded / e.total * 100, 131 loaded: e.loaded, 132 total: e.total 133 }); 134 }; 135 } 136 137 xhr.send(); 138 139 } catch (e) { 140 reject(new Error(e), null); 141 } 142 143 // returns a promise or undefined depending on whether a callback was 144 // provided 145 return promise; 146 }; 147 148 // export 149 module.exports = JSZipUtils; 150 151 // enforcing Stuk's coding style 152 // vim: set shiftwidth=4 softtabstop=4: 153 154 },{}]},{},[1]) 155 (1) 156 }); 157 ;
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.