From 128cf2eece4d0c6fde72a040b0653ee43a84fc11 Mon Sep 17 00:00:00 2001 From: JF Bastien Date: Mon, 2 Jan 2017 15:10:34 -0800 Subject: [PATCH] Use read if readbuffer is unavailable --- arch/wasm32/wasm.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/wasm32/wasm.js b/arch/wasm32/wasm.js index 438629d1..dda6a1b7 100644 --- a/arch/wasm32/wasm.js +++ b/arch/wasm32/wasm.js @@ -937,7 +937,10 @@ function load_wasm(file_path) { // dependencies. That would make it easier to do lazy loading. We could do // this by catching load exceptions + adding to ffi and trying again, but // we're talking silly there: modules should just tell us what they want. - instance = new WebAssembly.Instance(new WebAssembly.Module(readbuffer(file_path)), ffi) + const buf = (typeof readbuffer === 'function') + ? new Uint8Array(readbuffer(file_path)) + : read(file_path, 'binary'); + instance = new WebAssembly.Instance(new WebAssembly.Module(buf), ffi) heap = instance.exports.memory.buffer; heap_uint8 = new Uint8Array(heap); heap_size_bytes = heap.byteLength;