aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2017-09-27 23:27:40 +1000
committerdaurnimator <quae@daurnimator.com>2017-09-27 23:30:41 +1000
commitda1592c025a505eb94ef05a0baa916b829df3b62 (patch)
tree264a276b86bd3cc09a1463400ecca3b10120380f /src
parent6ac4cba004f4c53e5b44bf255a85545b44bf34c6 (diff)
downloadfengari-da1592c025a505eb94ef05a0baa916b829df3b62.tar.gz
fengari-da1592c025a505eb94ef05a0baa916b829df3b62.tar.bz2
fengari-da1592c025a505eb94ef05a0baa916b829df3b62.zip
src/loadlib.js: Invert condition so that code flows down
Diffstat (limited to 'src')
-rw-r--r--src/loadlib.js44
1 files changed, 22 insertions, 22 deletions
diff --git a/src/loadlib.js b/src/loadlib.js
index 4116b0a..04314b7 100644
--- a/src/loadlib.js
+++ b/src/loadlib.js
@@ -43,31 +43,31 @@ if (WEB) {
xhr.open("GET", path, false);
xhr.send();
- if (xhr.status >= 200 && xhr.status <= 299) {
- let code = xhr.response;
- /* Add sourceURL comment to get path in debugger+tracebacks */
- if (!/\/\/[#@] sourceURL=/.test(code))
- code += " //# sourceURL=" + path;
- let func;
- try {
- func = Function("fengari", code);
- } catch (e) {
- lua.lua_pushstring(L, lua.to_luastring(`${e.name}: ${e.message}`));
- return null;
- }
- let res = func(fengari);
- if (typeof res === "function" || (typeof res === "object" && res !== null)) {
- return res;
- } else if (res === void 0) { /* assume library added symbols to global environment */
- return window;
- } else {
- lua.lua_pushstring(L, lua.to_luastring(`library returned unexpected type (${typeof res})`));
- return null;
- }
- } else {
+ if (xhr.status < 200 || xhr.status >= 300) {
lua.lua_pushstring(L, lua.to_luastring(`${xhr.status}: ${xhr.statusText}`));
return null;
}
+
+ let code = xhr.response;
+ /* Add sourceURL comment to get path in debugger+tracebacks */
+ if (!/\/\/[#@] sourceURL=/.test(code))
+ code += " //# sourceURL=" + path;
+ let func;
+ try {
+ func = Function("fengari", code);
+ } catch (e) {
+ lua.lua_pushstring(L, lua.to_luastring(`${e.name}: ${e.message}`));
+ return null;
+ }
+ let res = func(fengari);
+ if (typeof res === "function" || (typeof res === "object" && res !== null)) {
+ return res;
+ } else if (res === void 0) { /* assume library added symbols to global environment */
+ return window;
+ } else {
+ lua.lua_pushstring(L, lua.to_luastring(`library returned unexpected type (${typeof res})`));
+ return null;
+ }
};
} else {
const pathlib = require('path');