Skip to content
This repository has been archived by the owner on Mar 13, 2018. It is now read-only.

Commit

Permalink
Fix asyncSeries implementation.
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinpschaaf committed Aug 22, 2014
1 parent eb2bdcc commit 2ee009b
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions htmltest.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,31 @@ if (window.top === window) {
};
}

window.asyncSeries = function(series, callback) {
window.asyncSeries = function(series, callback, forwardExceptions) {
series = series.slice();
var next = function(err) {
if (err) {
callback(err);
if (callback) {
callback(err);
}
} else {
var f = series.unshift();
var f = series.shift();
if (f) {
try {
f();
} catch(e) {
callback(e);
if (!forwardExceptions) {
f(next);
} else {
try {
f(next);
} catch(e) {
if (callback) {
callback(e);
}
}
}
} else {
callback();
if (callback) {
callback();
}
}
}
};
Expand Down

0 comments on commit 2ee009b

Please sign in to comment.