From ba0c8fda4187ba4a3aff78d7f3a2a33e0082f39e Mon Sep 17 00:00:00 2001 From: Guy Bedford Date: Sat, 7 Sep 2024 22:50:27 +0200 Subject: [PATCH] rework browser handling for buffer decoding (#104) --- src/lexer.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lexer.js b/src/lexer.js index e2f6952..1fc557d 100755 --- a/src/lexer.js +++ b/src/lexer.js @@ -92,9 +92,9 @@ function copyLE (src, outBuf16) { function getWasmBytes() { const binary = 'WASM_BINARY'; // This string will be replaced by build.js. - if ((typeof window !== 'undefined' || typeof self !== 'undefined') && typeof atob === 'function') - return Uint8Array.from(atob(binary), x => x.charCodeAt(0)); - return Buffer.from(binary, 'base64'); + if (typeof Buffer !== 'undefined') + return Buffer.from(binary, 'base64'); + return Uint8Array.from(atob(binary), x => x.charCodeAt(0)); } let initPromise;