aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2017-12-28 17:39:09 +1100
committerdaurnimator <quae@daurnimator.com>2017-12-28 17:44:24 +1100
commit746e9017b3b3989e501968c19f6fa82f831004c0 (patch)
tree4f95d3c91a1987b307273d5736e84e0b8570ba0b /src
parent2fb328badf87294a412c0430772461644a080b8c (diff)
downloadfengari-746e9017b3b3989e501968c19f6fa82f831004c0.tar.gz
fengari-746e9017b3b3989e501968c19f6fa82f831004c0.tar.bz2
fengari-746e9017b3b3989e501968c19f6fa82f831004c0.zip
src/loadlib.js: Add support for web worker global env
Diffstat (limited to 'src')
-rw-r--r--src/loadlib.js4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/loadlib.js b/src/loadlib.js
index eb382c1..bb7792a 100644
--- a/src/loadlib.js
+++ b/src/loadlib.js
@@ -5,12 +5,16 @@ const lua = require('./lua.js');
const lauxlib = require('./lauxlib.js');
const global_env = (function() {
+ /* global WorkerGlobalScope */ /* see https://github.com/sindresorhus/globals/issues/127 */
if (typeof process !== "undefined") {
/* node */
return global;
} else if (typeof window !== "undefined") {
/* browser window */
return window;
+ } else if (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope) {
+ /* web worker */
+ return self;
} else {
/* unknown global env */
return eval('this'); /* use non-strict mode to get global env */