| @@ -1,7 +1,7 @@ | ||
| 1 | 1 | /*! |
| 2 | 2 | |
| 3 | -JSZip v3.10.1 - A JavaScript class for generating and reading zip files | |
| 3 | +JSZip v3.10.2 - A JavaScript class for generating and reading zip files | |
| 4 | 4 | <http://stuartk.com/jszip> |
| 5 | 5 | |
| 6 | 6 | (c) 2009-2016 Stuart Knightley <stuart [at] stuartk.com> |
| 7 | 7 | Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip/main/LICENSE.markdown. |
| @@ -1056,9 +1056,9 @@ | ||
| 1056 | 1056 | JSZip.defaults = require("./defaults"); |
| 1057 | 1057 | |
| 1058 | 1058 | // TODO find a better way to handle this version, |
| 1059 | 1059 | // a require('package.json').version doesn't work with webpack, see #327 |
| 1060 | -JSZip.version = "3.10.1"; | |
| 1060 | +JSZip.version = "3.10.2"; | |
| 1061 | 1061 | |
| 1062 | 1062 | JSZip.loadAsync = function (content, options) { |
| 1063 | 1063 | return new JSZip().loadAsync(content, options); |
| 1064 | 1064 | }; |
| @@ -3389,18 +3389,19 @@ | ||
| 3389 | 3389 | exports.getTypeOf = function(input) { |
| 3390 | 3390 | if (typeof input === "string") { |
| 3391 | 3391 | return "string"; |
| 3392 | 3392 | } |
| 3393 | - if (Object.prototype.toString.call(input) === "[object Array]") { | |
| 3393 | + var proto = Object.prototype.toString.call(input); | |
| 3394 | + if (proto === "[object Array]") { | |
| 3394 | 3395 | return "array"; |
| 3395 | 3396 | } |
| 3396 | 3397 | if (support.nodebuffer && nodejsUtils.isBuffer(input)) { |
| 3397 | 3398 | return "nodebuffer"; |
| 3398 | 3399 | } |
| 3399 | - if (support.uint8array && input instanceof Uint8Array) { | |
| 3400 | + if (support.uint8array && proto === "[object Uint8Array]") { | |
| 3400 | 3401 | return "uint8array"; |
| 3401 | 3402 | } |
| 3402 | - if (support.arraybuffer && input instanceof ArrayBuffer) { | |
| 3403 | + if (support.arraybuffer && proto === "[object ArrayBuffer]") { | |
| 3403 | 3404 | return "arraybuffer"; |
| 3404 | 3405 | } |
| 3405 | 3406 | }; |
| 3406 | 3407 | |
| @@ -3491,23 +3492,31 @@ | ||
| 3491 | 3492 | |
| 3492 | 3493 | |
| 3493 | 3494 | var isBlob = support.blob && (data instanceof Blob || ["[object File]", "[object Blob]"].indexOf(Object.prototype.toString.call(data)) !== -1); |
| 3494 | 3495 | |
| 3495 | - if (isBlob && typeof FileReader !== "undefined") { | |
| 3496 | - return new external.Promise(function (resolve, reject) { | |
| 3497 | - var reader = new FileReader(); | |
| 3496 | + if (isBlob) { | |
| 3497 | + if (typeof Blob.prototype.arrayBuffer !== "undefined") { | |
| 3498 | + return data.arrayBuffer(); | |
| 3499 | + } else if (typeof FileReader !== "undefined") { | |
| 3500 | + return new external.Promise(function (resolve, reject) { | |
| 3501 | + var reader = new FileReader(); | |
| 3498 | 3502 | |
| 3499 | - reader.onload = function(e) { | |
| 3500 | - resolve(e.target.result); | |
| 3501 | - }; | |
| 3502 | - reader.onerror = function(e) { | |
| 3503 | - reject(e.target.error); | |
| 3504 | - }; | |
| 3505 | - reader.readAsArrayBuffer(data); | |
| 3506 | - }); | |
| 3507 | - } else { | |
| 3508 | - return data; | |
| 3503 | + reader.onload = function(e) { | |
| 3504 | + resolve(e.target.result); | |
| 3505 | + }; | |
| 3506 | + reader.onerror = function(e) { | |
| 3507 | + reject(e.target.error); | |
| 3508 | + }; | |
| 3509 | + reader.readAsArrayBuffer(data); | |
| 3510 | + }); | |
| 3511 | + } else { | |
| 3512 | + return external.Promise.reject( | |
| 3513 | + new Error(name + " is a Blob, but we have no way of reading it.") | |
| 3514 | + ); | |
| 3515 | + } | |
| 3509 | 3516 | } |
| 3517 | + | |
| 3518 | + return data; | |
| 3510 | 3519 | }); |
| 3511 | 3520 | |
| 3512 | 3521 | return promise.then(function(data) { |
| 3513 | 3522 | var dataType = exports.getTypeOf(data); |