Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

mark: async in place

  • Loading branch information...
commit 1062fbc90b3c0fbdbc3dcb816163cd08691f16f1 1 parent bce147e
Mark Needham mneedham authored

Showing 1 changed file with 11 additions and 2 deletions. Show diff stats Hide diff stats

  1. +11 2 pairstair.js
13 pairstair.js
@@ -155,8 +155,17 @@ var PairStair = function () {
155 155 }
156 156 };
157 157
158   - function asyncLoop(collection, loopFn, completionFn) {
159   -
  158 + function asyncLoop(collection, seedResult, loopFn, completionFn) {
  159 + var copy = collection.slice(0);
  160 + (function loop() {
  161 + var item = copy.shift();
  162 +
  163 + if(copy.length == 0) {
  164 + completionFn(seedResult);
  165 + } else {
  166 + loopFn(seedResult, loop);
  167 + }
  168 + })();
160 169 }
161 170
162 171 var daysSinceLastPaired = (function () {

0 comments on commit 1062fbc

Please sign in to comment.
Something went wrong with that request. Please try again.