code: function waitFor(check, cb, params) {
      params = params || {};
      if (typeof cb === 'object') {
        params = cb;
        cb = params.done;
      }
  
      var milliseconds = params.interval || 30,
          j = 0;
  
      var i = setInterval(function() {
        if (check()) {
          clearInterval(i);
          cb(null);
        }
  
        if (params.timeout && params.timeout - (j * milliseconds) <= 0) {
          clearInterval(i);
          cb(new Error('timeout'));
        }
  
        j++;
      }, milliseconds);
    }
docs: Async Helpers
  --------------
  
  Some helpful functions to deal with asynchronous matters.
   Waiting for something to happen