From 50754f02be402e68ad109b10bc4d07c8ad550cda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jimmy=20Wa=CC=88rting?= Date: Sat, 11 Sep 2021 11:13:50 +0200 Subject: [PATCH] browserify demo avoid readAsBinaryString [ci skip] --- demos/browserify/app.js | 16 +++++----------- demos/browserify/browserify.html | 1 - 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/demos/browserify/app.js b/demos/browserify/app.js index fd74022..e2b629d 100644 --- a/demos/browserify/app.js +++ b/demos/browserify/app.js @@ -95,10 +95,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); @@ -112,23 +108,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/browserify/browserify.html b/demos/browserify/browserify.html index b23c589..49d1803 100644 --- a/demos/browserify/browserify.html +++ b/demos/browserify/browserify.html @@ -41,7 +41,6 @@ Output Format:
Advanced Demo Options: Use Web Workers: (when available) -Use readAsBinaryString: (when available)