From 7c0b869c7fad25dfaafb890330db6de56c141504 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jimmy=20Wa=CC=88rting?= Date: Thu, 30 Sep 2021 19:31:52 +0200 Subject: [PATCH] webpack demo avoid readAsBinaryString [ci skip] --- demos/webpack/Makefile | 2 +- demos/webpack/app.js | 16 +++++----------- demos/webpack/core.html | 1 - demos/webpack/full.html | 1 - demos/webpack/main.html | 1 - demos/webpack/webpack.config.js | 3 ++- 6 files changed, 8 insertions(+), 16 deletions(-) diff --git a/demos/webpack/Makefile b/demos/webpack/Makefile index 98391aa..90946ca 100644 --- a/demos/webpack/Makefile +++ b/demos/webpack/Makefile @@ -1,5 +1,5 @@ TOOL=webpack -WPOPTS=--display-modules --display-reasons --profile +WPOPTS=--display-modules --display-reasons --profile --mode=development .PHONY: all all: main.min.js core.out.js full.out.js app.out.js diff --git a/demos/webpack/app.js b/demos/webpack/app.js index 57e4b7c..9eef9bf 100644 --- a/demos/webpack/app.js +++ b/demos/webpack/app.js @@ -87,10 +87,6 @@ var b64it = window.b64it = (function() { })(); var do_file = (function() { - var rABS = typeof FileReader !== "undefined" && (FileReader.prototype||{}).readAsBinaryString; - var domrabs = document.getElementsByName("userabs")[0]; - if(!rABS) domrabs.disabled = !(domrabs.checked = false); - var use_worker = typeof Worker !== 'undefined'; var domwork = document.getElementsByName("useworker")[0]; if(!use_worker) domwork.disabled = !(domwork.checked = false); @@ -104,23 +100,21 @@ var do_file = (function() { case XW.msg: cb(JSON.parse(e.data.d)); break; } }; - worker.postMessage({d:data,b:rABS?'binary':'array'}); + worker.postMessage({d:data,b:'array'}); }; return function do_file(files) { - rABS = domrabs.checked; use_worker = domwork.checked; var f = files[0]; var reader = new FileReader(); reader.onload = function(e) { - if(typeof console !== 'undefined') console.log("onload", new Date(), rABS, use_worker); + if(typeof console !== 'undefined') console.log("onload", new Date(), use_worker); var data = e.target.result; - if(!rABS) data = new Uint8Array(data); + data = new Uint8Array(data); if(use_worker) xw(data, process_wb); - else process_wb(X.read(data, {type: rABS ? 'binary' : 'array'})); + else process_wb(X.read(data, {type: 'array'})); }; - if(rABS) reader.readAsBinaryString(f); - else reader.readAsArrayBuffer(f); + reader.readAsArrayBuffer(f); }; })(); diff --git a/demos/webpack/core.html b/demos/webpack/core.html index 097e01e..6456899 100644 --- a/demos/webpack/core.html +++ b/demos/webpack/core.html @@ -41,7 +41,6 @@ Output Format:
Advanced Demo Options: Use Web Workers: (when available) -Use readAsBinaryString: (when available)

 
diff --git a/demos/webpack/full.html b/demos/webpack/full.html index 4d0ae68..96ea066 100644 --- a/demos/webpack/full.html +++ b/demos/webpack/full.html @@ -41,7 +41,6 @@ Output Format:
Advanced Demo Options: Use Web Workers: (when available) -Use readAsBinaryString: (when available)

 
diff --git a/demos/webpack/main.html b/demos/webpack/main.html index 2b128d9..5baade7 100644 --- a/demos/webpack/main.html +++ b/demos/webpack/main.html @@ -41,7 +41,6 @@ Output Format:
Advanced Demo Options: Use Web Workers: (when available) -Use readAsBinaryString: (when available)

 
diff --git a/demos/webpack/webpack.config.js b/demos/webpack/webpack.config.js index c241f5f..5a4fe0e 100644 --- a/demos/webpack/webpack.config.js +++ b/demos/webpack/webpack.config.js @@ -2,6 +2,7 @@ module.exports = { /* ensure that the XLSX variable is exported */ output: { + path: __dirname, libraryTarget: 'var', library: 'XLSX' }, @@ -23,4 +24,4 @@ module.exports = { process: false, Buffer: false } -} +};