Last active
January 28, 2017 14:09
-
-
Save ianwalter/4535307 to your computer and use it in GitHub Desktop.
Re-writing mariusa's example from https://github.com/caolan/async/issues/114
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async.parallel({ | |
a: function(callback) { | |
fs.readFile('a.html', 'utf8', function(err, a) { | |
if (err) callback(err); | |
console.log('read a'); | |
callback(null, a); | |
}); | |
}, | |
b: function(callback) { | |
fs.readFile('b.html', 'utf8', function(err, b) { | |
if (err) callback(err); | |
console.log('read b'); | |
callback(null, b); | |
}); | |
} | |
}, function (err, results) { | |
console.log('a:' + results.a); | |
console.log('b:' + results.b); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You know this is incorrect right? The callback would get called twice in the parallel functions. Either place the second callback in an else block or use
if (err) **return** callback(err);