From 515c7dfe26135a1961ae9d71c5c4563f62c9d7b4 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Tue, 16 Oct 2012 10:30:04 -0400 Subject: fix running in --use-strict mode. closes #189 --- lib/async.js | 8 ++++++-- test/test-strict.js | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 test/test-strict.js 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"); +}); -- cgit v1.2.1