Permalink
Browse files

mark: async in place

  • Loading branch information...
1 parent bce147e commit 1062fbc90b3c0fbdbc3dcb816163cd08691f16f1 @mneedham mneedham committed Sep 25, 2011
Showing with 11 additions and 2 deletions.
  1. +11 −2 pairstair.js
View
13 pairstair.js
@@ -155,8 +155,17 @@ var PairStair = function () {
}
};
- function asyncLoop(collection, loopFn, completionFn) {
-
+ function asyncLoop(collection, seedResult, loopFn, completionFn) {
+ var copy = collection.slice(0);
+ (function loop() {
+ var item = copy.shift();
+
+ if(copy.length == 0) {
+ completionFn(seedResult);
+ } else {
+ loopFn(seedResult, loop);
+ }
+ })();
}
var daysSinceLastPaired = (function () {

0 comments on commit 1062fbc

Please sign in to comment.