ASYNC ARRAY (START)
349451
function(callback) { // # 1

          var startReplicas = Math.pow(Number(self.conf.balancing['REPLICA_BASE_NUMBER']), Number(self.conf.balancing['MAX_LEVEL']));

          var address = '';
          if (self.conf.zookeeper) {
            if (typeof self.conf.zookeeper === 'string' || self.conf.zookeeper instanceof String) {
              address = self.conf.zookeeper;
            } else {
              if (self.conf.zookeeper.address) address = self.conf.zookeeper.address;
            }
          }

          self.nodeManager = new NodeManager(
            address,
            false,
            function(err, message) {
              if (!err) {
                console.info(' (init) ZOOKEEPER is connected');
                self.nodeManager.addServerNode(self.conf, startReplicas, function(err, path, replicas) {

                  //if (!err) console.info('        ZOOKEEPER /' + self.conf.host + ':' + self.conf.port);

                  var serverName = path.substring(path.lastIndexOf('/') + 1, path.length);
                  self.serverNodePath = path;

                  self.serverName = serverName.split('^')[0];

                  if (replicas) {
                    self.replicas = replicas;
                  } else {
                    self.replicas = startReplicas;
                  }

                  // init balacing config
                  self.nodeManager.getConfigInfo('balancing', function(data) {
                    if (data) {

                      self.conf.balancing = data;
                      var configReplica = Math.pow(Number(self.conf.balancing['REPLICA_BASE_NUMBER']), Number(self.conf.balancing['MAX_LEVEL']));

                      if (self.replicas != configReplica) {
                        self._changeReplicas(configReplica);
                      }
                    }
                  });

                  callback(err);
                });
              } else {
                callback(err, message);
              }
            }
          );
        }
136679
function each(items, numParralel, fn, done) {
    if (done === undefined) {
      done = fn; fn = numParralel;
      numParralel = 3;
    }

    if (numParralel <= 0) numParralel = 1;

    let doing = 0;
    let numProcessing = 0;
    let numDone = 0;
    const numTotal = items.length;
    const results = [];
    return nextItem();

    function nextItem() {
      // We done-check first in case of emtpty array
      if (numDone >= numTotal) return done(null, results);

      // Batch (or call next item)
      while (doing < numTotal && numProcessing < numParralel) {
        callFn(fn, items[doing++], onDone);
        numProcessing++;
      }
      return;

      // All done
      function onDone(err, result) {
        if (err) return done(err);

        results.push(result);
        numProcessing--;
        numDone++;
        return nextItem();
      }
    }
  }
494720
function asyncer (tasks, cb) {

    cb = cb || noop6;

    if (typpy(tasks, Function)) {
        if (tasks.length >= 1) {
            return tasks(cb);
        }
        return fnResult(tasks, cb);
    }

    let normalize = tsks => tsks.map(c => {
        if (typpy(c, Function) && c.length >= 1) {
            return c;
        }

        return done => {
            asyncer(c, done)
        };
    });

    if (typpy(tasks, Object)) {
        tasks = normalize(tasks.parallel || tasks.p);
        sameTime(tasks, cb);
        return;
    }

    if (typpy(tasks, Array)) {
        tasks = normalize(tasks);
        oneByOne(tasks, cb);
        return;
    }

    throw new TypeError("The tasks should be an array or an object.");
}
904192
function execEach(items, options) {
    if (_.size(items) === 0) return Q();
    var concurrents = 0, d = Q.defer(), pending = [];

    options = _.defaults(options || {}, {
        max: 100,
        fn: function() {}
    });


    function startItem(item, i) {
        if (concurrents >= options.max) {
            pending.push([item, i]);
            return;
        }

        concurrents++;
        Q()
        .then(function() {
            return options.fn(item, i);
        })
        .then(function() {
            concurrents--;

            // Next pending
            var next = pending.shift();

            if (concurrents === 0 && !next) {
                d.resolve();
            } else if (next) {
                startItem.apply(null, next);
            }
        })
        .fail(function(err) {
            pending = [];
            d.reject(err);
        });
    }

    _.each(items, startItem);

    return d.promise;
}
856144
function readAsByteArray(chunk, callback) {
  let reader = new FileReader();
  reader.onload = () => {
    callback(null, new Uint8Array(reader.result));
  };
  reader.onerror = (err) => {
    callback(err);
  };
  reader.readAsArrayBuffer(chunk);
}
1006064
function startReadyProcesses()
    {
        // Start as many processes as we can!
        //writeToLog("INFO", "***** maxNumberOfRunningProcesses = " + maxNumberOfRunningProcesses + "; numberOfRunningProcesses = " + numberOfRunningProcesses);
        var numVertices = graph.vertexCount();
        var vertexIds = graph.getVertexIds();

        for(var i = 0; i < numVertices; i++)
        {
            if(graph.getVertex(vertexIds[i]).state == "READY")
            {
                if(maxNumberOfRunningProcesses > 0 && numberOfRunningProcesses < maxNumberOfRunningProcesses)
                {
                    numberOfRunningProcesses++;
                    graph.getVertex(vertexIds[i]).setState("IN_PROGRESS");
                }
                else if(maxNumberOfRunningProcesses <= 0)
                {
                    numberOfRunningProcesses++;
                    graph.getVertex(vertexIds[i]).setState("IN_PROGRESS");
                }
            }
        }
    }
891262
async function start () {
    var config = this.immutableApp
    var module = this
    // initialize app if not yet initialized
    if (!config.initialized) {
        try {
            await this.init()
        }
        catch (err) {
            throw err
        }
    }
    // run any start functions for modules
    await Promise.each(_.values(config.modules), subModule => {
        // if onStart is function run it
        if (typeof subModule.onStart === 'function') {
            return subModule.onStart(config)
        }
    })
    debug('start Promise')
    // create new promise that will be resolved when server started
    return new Promise(function (resolve, reject) {
        // create HTTP server
        config.server = http.createServer(config.express)
        // create error handler
        config.server.on('error', function (err) {
            // only deal with listen errors
            if (err.syscall !== 'listen') {
                throw err
            }
            // log error if logging enable
            if (config.log) {
                // error msg detail
                var msg
                // get specific errors
                if (err.code === 'EACCES') {
                    msg = 'permission denied'
                }
                else if (err.code === 'EADDRINUSE') {
                    msg = 'address in use'
                }
                else {
                    msg = err.code
                }
                // log error
                console.error('listen on port '+config.port+' failed '+msg)
            }
            // if exit on error is set then exit
            if (config.exit) {
                process.exit(1)
            }
            // reject promise with error
            reject(err)
        })
        debug('start listen')
        // listen on provided port, on all network interfaces.
        config.server.listen(config.port, function () {
            // log start if logging enabled
            if (config.log) {
                console.log(module.name+' listening on port '+config.port)
            }
            // set started to true
            config.started = true
            // resolve promise
            resolve()
        })
    })
    // after starting check the START_TEST_ONLY flag and shut back down if it
    // is set - this flag is used to validate app config and sync models
    .then(() => {
        if (process.env.START_TEST_ONLY) {
            return this.stop().then(() => {
                if (config.log) {
                    console.log('START_TEST_ONLY success - server stopped')
                }
                process.exit()
            })
        }
    })
}
970747
function(array, fun, init) {
      var ret = [];
      var acc = init;

      _.each(array, function(v,k) {
        acc = fun(acc, array[k]);
        ret.push(acc);
      });

      return ret;
    }
1291905
public void beginArray() throws IOException {
    int p = peeked;
    if (p == PEEKED_NONE) {
      p = doPeek();
    }
    if (p == PEEKED_BEGIN_ARRAY) {
      push(JsonScope.EMPTY_ARRAY);
      pathIndices[stackSize - 1] = 0;
      peeked = PEEKED_NONE;
    } else {
      throw new IllegalStateException("Expected BEGIN_ARRAY but was " + peek() + locationString());
    }
  }
816361
def RunAsync(self):
    """"""
    self.running_thread = threading.Thread(
        name=self.thread_name, target=self._RunLoop)
    self.running_thread.daemon = True
    self.running_thread.start()
    return self.running_thread
72084
function forAsync(items, iter, callback) {
	var keys = Object.keys(items);
	var step = function (err, callback) {
		nextTick(function () {
			if (err) {
				return callback(err);
			}
			if (keys.length === 0) {
				return callback();
			}
			var key = keys.pop();
			iter(items[key], key, function (err) {
				step(err, callback);
			});
		});
	};
	step(null, callback);
}
41421
function forEach(data, task, callback) {

		var wrapTask,
		    isArray,
		    subject,
		    test,
		    len,
		    i;

		isArray = Array.isArray(data);
		i = -1;

		if (isArray) {
			subject = data;

			wrapTask = function wrapTask(next) {
				task(subject[i], i, next);
			};
		} else {
			subject = Bound.Object.dissect(data);

			wrapTask = function wrapTask(next) {
				task(subject[i].value, subject[i].key, next);
			};
		}

		len = subject.length;
		test = function test() {
			return ++i < len;
		};

		return Blast.Collection.Function['while'](test, wrapTask, callback);
	}
811920
function makeAsync(cb) {
    return function () {
        var args = arguments;
        process.nextTick(function () {
            cb.apply(null, args);
        });
    };
}
1356116
def _on_startup(self, *args):
        
        yield from Controller.instance().start()
        # Because with a large image collection
        # without md5sum already computed we start the
        # computing with server start
        asyncio.async(Qemu.instance().list_images())
1038584
private void asyncMoreRequest(int startRow) {
    try {
      DataRequest moreRequest = new DataRequest();
      moreRequest.queryId = queryId;
      moreRequest.startRow = startRow;
      moreRequest.maxSize = maxBatchSize;
      logger.debug("Client requesting {} .. {}", startRow, (startRow + maxBatchSize - 1));

      DataResponse response = server.data(moreRequest);
      logger.debug("Client got response {} .. {}, more={}",
          new Object[] { response.startRow, (response.startRow + response.data.size() - 1), response.more });
      nextData.add(new Window(response.data, response.more));
    } catch (AvroRemoteException e) {
      this.nextData.addError(toSparqlException(e));
    } catch (Throwable t) {
      this.nextData.addError(t);
    }
  }
1093195
function _asyncEverySeries (arr, iterator, callback) {
  if (!arr.length) {
    return callback();
  }

  var completed = 0;
  (function iterate() {
    iterator(arr[completed], function (err) {
      if (err || err === false) {
        callback(err);
        callback = function () {};
      }
      else {
        completed += 1;
        if (completed === arr.length) {
          callback();
        }
        else {
          iterate();
        }
      }
    });
  })();
}
589683
async function start () {
  if (!process.argv.slice(2).length) {
    return program.outputHelp()
  }

  program.parse(process.argv)

  try {
    const rendered = await render(program)
    if (rendered) console.log(rendered)
  } catch (err) {
    console.log(chalk.red(err))
  }
}