aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2012-02-29 11:15:04 -0800
committerAlon Zakai <alonzakai@gmail.com>2012-02-29 11:15:04 -0800
commit4c16a991274dd4f1e37a707b122640f1f844fdba (patch)
tree0d3502daedc3139f7e1341a5b20b26010cef4a55 /src
parent196922073e389a800ab346c57e0412869102c26b (diff)
do not pollute global scope except for node (where we must)
Diffstat (limited to 'src')
-rw-r--r--src/compiler.js5
-rw-r--r--src/shell.js5
2 files changed, 10 insertions, 0 deletions
diff --git a/src/compiler.js b/src/compiler.js
index 1876ee1c..9e239c1d 100644
--- a/src/compiler.js
+++ b/src/compiler.js
@@ -17,6 +17,11 @@ var ENVIRONMENT_IS_WEB = typeof window === 'object';
var ENVIRONMENT_IS_WORKER = typeof importScripts === 'function';
var ENVIRONMENT_IS_SHELL = !ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_NODE && !ENVIRONMENT_IS_WORKER;
+if (!ENVIRONMENT_IS_NODE) {
+ // Node needs these in the global scope, everywhere else, cleaner to not pollute the global scope
+ eval('var print, printErr, read, load, arguments_;');
+}
+
if (ENVIRONMENT_IS_NODE) {
// Expose functionality in the same simple way that the shells work
print = function(x) {
diff --git a/src/shell.js b/src/shell.js
index d67cc45a..b45d2c7d 100644
--- a/src/shell.js
+++ b/src/shell.js
@@ -9,6 +9,11 @@ var ENVIRONMENT_IS_WEB = typeof window === 'object';
var ENVIRONMENT_IS_WORKER = typeof importScripts === 'function';
var ENVIRONMENT_IS_SHELL = !ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_NODE && !ENVIRONMENT_IS_WORKER;
+if (!ENVIRONMENT_IS_NODE) {
+ // Node needs these in the global scope, everywhere else, cleaner to not pollute the global scope
+ eval('var print, printErr, read, load, arguments_;');
+}
+
if (ENVIRONMENT_IS_NODE) {
// Expose functionality in the same simple way that the shells work
print = function(x) {