Queues callbacks while the condition tests true. Similar behaviour as async.whilst.
172059
function QueueWhile(test, delayRetry) {
  this.queue = async.queue(function (task, queueCallback) {
    async.whilst(
      test,
      function(cb) {
        //Retry in a while
        if (delayRetry) {
          setTimeout(cb, delayRetry);
        }
        else {
          setImmediate(cb);
        }
      },
      function() {
        queueCallback(null, null);
      }
    );
  }, 1);
}
46118
def wait(self, until=0):
        
        if self._count != until:
            self._waiters.setdefault(until, []).append(compat.getcurrent())
            scheduler.state.mainloop.switch()
1318010
function waitUntil(check, onComplete, delay, timeout) {
        if (check()) {
            onComplete();
            return;
        }

        if (!delay) delay = 100;
        var timeoutPointer = void 0;
        var intervalPointer = setInterval(function () {
            if (!check()) return;
            clearInterval(intervalPointer);
            if (timeoutPointer) clearTimeout(timeoutPointer);
            onComplete();
        }, delay);
        if (timeout) timeoutPointer = setTimeout(function () {
            clearInterval(intervalPointer);
        }, timeout);
    }
953894
def _wait_non_ressources(self, callback):
        """"""  # noqa: E501
        self.trigger = threading.Lock()
        self.was_ended = False
        self.trigger.acquire()
        self.trigger.acquire()
        if not self.was_ended:
            callback(self)
487885
def flush(self):
        

        done = threading.Event()

        def _callback():
            done.set()

        self.defer(_callback)
        done.wait()
977184
def callback_result(self):
        """"""
        if self._state == self._PENDING:
            self._loop.run_until_complete(self)
        if self._callbacks:
            result = self._callback_result
        else:
            result = self.result()
        return result
713629
def wait(self):
        
        d = defer.Deferred()
        if self._result is None:
            self._waiters.append(d)
        else:
            self._fire_deferred(d)
        return d
833728
def wait_until_not(self, condition):
        
        return WebDriverWait(self.driver, self.timeout).until_not(condition)
1336010
function _detect(eachFn, arr, iterator, mainCallback) {
  eachFn(arr, function (x, index, callback) {
    iterator(x, function (v, result) {
      if (v) {
        mainCallback(result || x);
        mainCallback = async.noop;
      } else {
        callback();
      }
    });
  }, function () {
    mainCallback();
  });
}
373890
function( callback ) {
		var self = this;
		if (!callback) callback = function(){};

		// If there are no queued requests, fire callback as-is
		if (this.queuedRequests.length === 0) {
			callback( null, this.database );
			return;
		}

		// First make sure that there are no bundles pending loading
		var pendingLoading = false;
		for (var i=0; i<this.queuedRequests.length; ++i) {
			if (this.queuedRequests[i].status === PBUND_REQUESTED) {
				pendingLoading = true;
				break;
			}
		}

		////////////////////////////////////////////////////////
		// Iteration 1 - PBUND_REQUESTED -> PBUND_LOADED
		// ----------------------------------------------------
		// Download all bundles in pending state.
		////////////////////////////////////////////////////////

		if (pendingLoading) {

			// Prepare the callbacks for when this is finished
			var state = { 'counter': 0 }
			var continue_callback = (function() {
				// When reached 0, continue loading
				if (--this.counter === 0)
					self.__process( callback );
			}).bind(state);

			// Place all requests in parallel
			var triggeredError = false;
			for (var i=0; i<this.queuedRequests.length; ++i) {
				var req = this.queuedRequests[i], part = this.progressManager.part();
				if (req.status === PBUND_REQUESTED) {

					// Download bundle from URL(s)
					state.counter++;
					req.buffer = downloadArrayBuffers(req.url, part,
						(function(req) {
							return function( err ) {

								// Handle errors
								if (err) {
									if (triggeredError) return;
									var errMsg = "Error downloading bundle: "+err;
									if (req.callback) req.callback( errMsg, null);
									if (callback) callback(errMsg, null);
									triggeredError = true;
									return;
								}

								// Keep buffer and mark as loaded
								req.status = PBUND_LOADED;
								// Continue
								continue_callback();
							}
						})(req)
					);

				}
			}

			// Do not continue, we ar asynchronous
			return;
		}

		////////////////////////////////////////////////////////
		// Iteration 2 - PBUND_LOADED -> PBUND_PARSED
		// ----------------------------------------------------
		// Parse all loaded bundles (synchronous)
		////////////////////////////////////////////////////////

		for (var i=0; i<this.queuedRequests.length; ++i) {
			var req = this.queuedRequests[i];
			if (req.status === PBUND_LOADED) {
				// try {

				// Create bundle from sparse or compact format
				var bundle;
				if (req.buffer.length === 1) {
					bundle = new BinaryBundle( req.buffer[0], self.profile );
				} else {
					bundle = new BinaryBundle( req.buffer, self.profile );
				}

				// Parse bundle
				parseBundle( bundle, self.database );

				// Trigger bundle callback
				if (req.callback) req.callback( null, req.bundle );

				// } catch (e) {

				// 	// Update bundle status
				// 	req.status = PBUND_ERROR;

				// 	// Fire error callbacks and exit
				// 	var errMsg = "Error parsing bundle: "+e.toString();
				// 	if (req.callback) req.callback( errMsg, null);
				// 	if (callback) callback(errMsg, null);
				// 	return;

				// }
			}
		}

		// We are ready
		this.queuedRequests = [];
		callback( null, this.database );

	}
365751
function(asyncFunc, callback) {
  asyncFunc(function(err, buffer) {
    if(callback) {
      callback(err, buffer.toHex().toString());
    }
  });
}
702468
function() {
		var i = 0;
		while (i<_callbacks.length) {
			var deps = _callbacks[i][0],
				func = _callbacks[i][1],
				n = 0;
			while (n<deps.length) {
				if (areDeepDepsDefined(deps[n])) {
					deps.splice(n, 1);
				}
				else {
					n++;
				}
			}
			if (!deps.length) {
				_callbacks.splice(i, 1);
				if (func != null) {
					setTimeout(func, 0);
				}
			}
			else {
				i++;
			}
		}
	}
51770
def __callbacks(self, msg):
            ''''''
            if self.callback:
                self.callback(msg, *self.callback_args, **self.callback_kwargs)
649226
def _multiple_callbacks(callbacks, *args, **kwargs):
    
    if isinstance(callbacks, list):
        for cb in callbacks:
            cb(*args, **kwargs)
        return
    if callbacks:
        callbacks(*args, **kwargs)
1362964
def _do_callbacks(self):
        """"""
        self._done = False

        while self._callbacks and not self._cancelled:
            cb, eb, cb_args, cb_kwargs, eb_args, eb_kwargs = self._callbacks.pop()
            if cb and not self._exception:
                try:
                    self._result = cb(self._result, *cb_args, **cb_kwargs)
                    self._exception = False
                except Exception as e:
                    #logger.exception('deferred got exception while doing callback')
                    self._exception = True
                    self._result = e
                    self._tb_info = ''.join(traceback.format_tb(sys.exc_info()[2]))
            elif eb and self._exception:
                try:
                    self._result = eb(self._result, *eb_args, **eb_kwargs)
                    self._exception = False
                except Exception as e:
                    #logger.exception('deferred got exception while doing callback')
                    self._exception = True
                    self._result = e
                    self._tb_info = ''.join(traceback.format_tb(sys.exc_info()[2]))


        if self._exception:
            if Deferred.warnings:
                logger.warn('Unhandled Exception: ' + str(self._result))
            self._last_exception.exception = self._result
            self._last_exception.tb_info = self._tb_info
        else:
            self._last_exception.exception = None
            self._last_exception.tb_info = None

        self._done = True
674418
function() {
    if (_xhr.readyState === 4) {
      var result = Result(_xhr);
      // ready
      __callback_func('ready')(result, _this);
      // success
      if (_xhr.status === 200) __callback_func('success')(result, _this);
      // fail
      else __callback_func('fail')(result, _this);
    }
  }
433425
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);
  }