From 714162eb72d9a532b68d8150f6b21ea8deb73bcd Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Wed, 14 Nov 2018 11:05:14 +0000 Subject: [PATCH] Support multiple versions of Emscripten (module.Runtime.addFunction vs. module.addFunction) --- wrapper.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/wrapper.js b/wrapper.js index 4d050535..0cb6212b 100644 --- a/wrapper.js +++ b/wrapper.js @@ -34,16 +34,21 @@ function setupMethods (soljson) { }; }; } - var cb = soljson.Runtime.addFunction(wrapCallback(readCallback)); + + // This is to support multiple versions of Emscripten. + var addFunction = soljson.addFunction || soljson.Runtime.addFunction; + var removeFunction = soljson.removeFunction || soljson.Runtime.removeFunction; + + var cb = addFunction(wrapCallback(readCallback)); var output; try { args.push(cb); output = compile.apply(undefined, args); } catch (e) { - soljson.Runtime.removeFunction(cb); + removeFunction(cb); throw e; } - soljson.Runtime.removeFunction(cb); + removeFunction(cb); return output; };