[Pkg-javascript-commits] [node-async] 216/480: fix running in --use-strict mode. closes #189

Jonas Smedegaard js at moszumanska.debian.org
Fri May 2 08:58:27 UTC 2014


This is an automated email from the git hooks/post-receive script.

js pushed a commit to branch master
in repository node-async.

commit 515c7dfe26135a1961ae9d71c5c4563f62c9d7b4
Author: Andrew Kelley <superjoe30 at gmail.com>
Date:   Tue Oct 16 10:30:04 2012 -0400

    fix running in --use-strict mode. closes #189
---
 lib/async.js        |  8 ++++++--
 test/test-strict.js | 19 +++++++++++++++++++
 2 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/lib/async.js b/lib/async.js
index bbbd05c..2c79f47 100644
--- a/lib/async.js
+++ b/lib/async.js
@@ -4,8 +4,12 @@
     var async = {};
 
     // global on the server, window in the browser
-    var root = this,
-        previous_async = root.async;
+    var root, previous_async;
+
+    root = this;
+    if (root != null) {
+      previous_async = root.async;
+    }
 
     async.noConflict = function () {
         root.async = previous_async;
diff --git a/test/test-strict.js b/test/test-strict.js
new file mode 100644
index 0000000..39c14bf
--- /dev/null
+++ b/test/test-strict.js
@@ -0,0 +1,19 @@
+// run like this:
+// node --harmony --use-strict test-strict.js
+
+var async = require('../lib/async');
+
+function hi() {
+  let i = "abcd";
+  for (let i = 0; i < 3; i++) {
+    console.log(i);
+  }
+  console.log(i);
+}
+function hi2(){
+  console.log("blah");
+}
+
+async.parallel([hi, hi2], function() {
+  console.log("done");
+});

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-async.git



More information about the Pkg-javascript-commits mailing list