From a953f717523a844a3a45810a5acc6630383884d3 Mon Sep 17 00:00:00 2001 From: Richard Moore Date: Sun, 7 Mar 2021 17:37:49 -0500 Subject: [PATCH] Fixed shims from not displaying debug information. --- packages/shims/src/index.js | 38 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/packages/shims/src/index.js b/packages/shims/src/index.js index 330683cf2..2281298d7 100644 --- a/packages/shims/src/index.js +++ b/packages/shims/src/index.js @@ -85,27 +85,25 @@ var fr = new FileReader(); try { fr.readAsArrayBuffer(new Blob([ "hello" ], { type: "text/plain" })); - return; - } catch (error) { } - - shims.push("FileReader.prototype.readAsArrayBuffer"); - FileReader.prototype.readAsArrayBuffer = function (blob) { - if (this.readyState === this.LOADING) throw new Error("InvalidStateError"); - this._setReadyState(this.LOADING); - this._result = null; - this._error = null; - var fr = new FileReader(); - fr.onloadend = () => { - var content = atob(fr.result.split(",").pop().trim()); - var buffer = new ArrayBuffer(content.length); - var view = new Uint8Array(buffer); - view.set(Array.from(content).map(c => c.charCodeAt(0))); - this._result = buffer; - this._setReadyState(this.DONE); - }; - fr.readAsDataURL(blob); + } catch (error) { + shims.push("FileReader.prototype.readAsArrayBuffer"); + FileReader.prototype.readAsArrayBuffer = function (blob) { + if (this.readyState === this.LOADING) { throw new Error("InvalidStateError"); } + this._setReadyState(this.LOADING); + this._result = null; + this._error = null; + var fr = new FileReader(); + fr.onloadend = () => { + var content = atob(fr.result.split(",").pop().trim()); + var buffer = new ArrayBuffer(content.length); + var view = new Uint8Array(buffer); + view.set(Array.from(content).map(c => c.charCodeAt(0))); + this._result = buffer; + this._setReadyState(this.DONE); + }; + fr.readAsDataURL(blob); + } } - } catch (error) { console.log("Missing FileReader; unsupported platform"); }