diff options
author | Caolan McMahon <caolan@caolanmcmahon.com> | 2013-01-31 04:45:49 -0800 |
---|---|---|
committer | Caolan McMahon <caolan@caolanmcmahon.com> | 2013-01-31 04:45:49 -0800 |
commit | 1818b64c24becfa108f39a6bff4e9feafaf4e90a (patch) | |
tree | cc3ca7ef0ae89574c869cb109e274b4c9af1b44e | |
parent | 9a2594e52ecd3bce2bcb7c4adc2ee2bb2226e78d (diff) | |
parent | 515c7dfe26135a1961ae9d71c5c4563f62c9d7b4 (diff) | |
download | async-1818b64c24becfa108f39a6bff4e9feafaf4e90a.tar.gz |
Merge pull request #194 from superjoe30/fix-use-strict
fix running in --use-strict mode. closes #189
-rw-r--r-- | lib/async.js | 8 | ||||
-rw-r--r-- | test/test-strict.js | 19 |
2 files changed, 25 insertions, 2 deletions
diff --git a/lib/async.js b/lib/async.js index 0480a30..96bc67a 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"); +}); |