Skip to content

Commit 84ceb0f

Browse files
committed
Make the dataset files add their variable to the global scope on Node
So that they are easier to use for readers who haven't gotten to CommonJS modules yet.
1 parent 9e08a7e commit 84ceb0f

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

code/game_levels.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,3 +174,5 @@ var GAME_LEVELS = [`
174174

175175
if (typeof module != "undefined" && module.exports && (typeof window == "undefined" || window.exports != exports))
176176
module.exports = GAME_LEVELS;
177+
if (typeof global != "undefined" && !global.GAME_LEVELS)
178+
global.GAME_LEVELS = GAME_LEVELS;

code/jacques_journal.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,3 +95,5 @@ const JOURNAL = [
9595
// `require('./path/to/jaques_journal.js')` will get you the array.
9696
if (typeof module != "undefined" && module.exports && (typeof window == "undefined" || window.exports != exports))
9797
module.exports = JOURNAL;
98+
if (typeof global != "undefined" && !global.JOURNAL)
99+
global.JOURNAL = JOURNAL;

code/load.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// load dependency files into the global namespace, so that the
44
// examples can run on node.
55

6-
module.exports = function() {
7-
for (var i = 0; i < arguments.length; i++)
8-
(1,eval)(require("fs").readFileSync(__dirname + "/../" + arguments[i], "utf8"));
9-
};
6+
module.exports = function(...args) {
7+
for (let arg of args)
8+
(1,eval)(require("fs").readFileSync(__dirname + "/../" + arg, "utf8"))
9+
}

code/scripts.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,3 +1119,5 @@ const SCRIPTS = [
11191119
// `require('./path/to/jaques_journal.js')` will get you the array.
11201120
if (typeof module != "undefined" && module.exports && (typeof window == "undefined" || window.exports != exports))
11211121
module.exports = SCRIPTS;
1122+
if (typeof global != "undefined" && !global.SCRIPTS)
1123+
global.SCRIPTS = SCRIPTS;

0 commit comments

Comments
 (0)