Comparing version 1.0.0 to 1.1.0
@@ -1,2 +0,4 @@ | ||
var util = require('util'); | ||
var isError = function(e) { | ||
return Object.prototype.toString.call(e) === '[object Error]' || e instanceof Error; | ||
}; | ||
@@ -25,3 +27,3 @@ module.exports = function(afterAllCb) { | ||
if (done) return; | ||
if (util.isError(err)) { | ||
if (isError(err)) { | ||
done = true; | ||
@@ -28,0 +30,0 @@ return afterAllCb(err); |
{ | ||
"name": "after-all", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "Execute several async functions and get a callback when they are all done", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -57,5 +57,10 @@ # after-all | ||
db.findProducts(next(function(err, docs) { | ||
resp.products = docs; | ||
})); | ||
var cb = next(); // wrapping the callback is optional | ||
db.findProducts(function(err, docs) { | ||
db.findProductsSales(function(sales) { | ||
resp.products = docs; | ||
resp.productsSales = sales; | ||
cb(); | ||
}); | ||
}); | ||
@@ -72,2 +77,8 @@ db.findTodaySalesAmount(next(function(err, amount) { | ||
As you can see, passing a callback to the `next` function is optional and it can be | ||
useful to not pass any when you are doing more than one sequetial async operations as | ||
in the example above. | ||
Also notice that all the calls to `next` must be done on the same tick. | ||
## Error handling | ||
@@ -74,0 +85,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7632
144
91