async.whilst( function () { return retry > 0 && flag;
async.whilst(function () { return queue.length; }, function (fn) { queue.shift()(fn); }, function () { that.queued = false; });
afterEach(done => { consumer1.resume(); consumer2.pause(); async.whilst(() => qpSite1.scheduledResume !== null || !qpSite2.scheduledResume, cb => setTimeout(() => { qpSite1._deleteScheduledResumeService(); qpSite2.scheduleResume(futureDate); cb(); }, 1000), err => { assert.ifError(err); zkHelper.reset(done); }); });
//this.connNum++; pool.open(connStr, (err, conn) => { let i = 0; async.whilst(() => i<sql.length, (next) => { let stat = sql[i++]; this.runSQL(conn, stat); next(); },(err)=>{ conn.close(); if(i==sql.length){ if(callBack && callBack.success) callBack.success(); } else{ if(callBack && callBack.error) callBack.error(); } //this.connNum--; }); })
async.whilst((callback) => { callback(null, this._queue.paused); }, (callback) => { setTimeout(() => callback(null), 500); }, (err) => { request.get({ uri: uri, headers: this.getHeaders() }).then((res) => { const data = JSON.parse(res); callback(null, data); }).catch((err) => { callback(err, null); }); });
/** * Returns the next date and time that the market will close. * @author Torrey Leonard <https://github.com/Ladinn> * @returns {Promise<Date>} */ getNextClose() { const _this = this; return new Promise((resolve, reject) => { let next = null; let days = moment().isAfter(_this.getClose()) ? 1 : 0; async.whilst( () => { return next === null; }, callback => { let newDate = moment().add(days, 'days'); _this.getHoursOn(newDate.toDate()).then(hours => { if (hours.isOpen) next = hours.close; callback(); }).catch(error => reject(new LibraryError(error))); }, () => { resolve(next); }) }) }
function multipleOpen (filename, N, callback) { async.whilst( function () { return i < N; } , function (cb) { fs.open(filename, 'r', function (err, fd) { i += 1; if (fd) { fds.push(fd); } return cb(err); }); } , callback); }
drainBuffer() { if (this.bufferDraining) { return Promise.resolve(); } this.bufferDraining = true; return new Promise((resolve, reject) => { async.whilst( () => this.buffer.length !== 0, next => this.runBatch() .then(() => next()) .catch(error => next(error)), error => { this.bufferDraining = false; if (error) { return reject(error); } resolve(); } ); }); }
function postVotes (params, done) { var count = 0; var limit = 1; async.whilst( function () { return count < limit; }, function (untilCb) { node.onNewBlock(function (err) { count++; return untilCb(); }); }, function (err) { async.eachSeries(params.delegates, function (delegate, eachCb) { var transaction = node.ark.vote.createVote(params.passphrase, [params.action + delegate]); postVote(transaction, function (err, res) { params.voteCb(err, res); return eachCb(); }); }, function (err) { node.onNewBlock(function (err) { return done(err); }); }); } ); }
async.whilst( function () { return (block.height < lastBlock.height); }, function (next) { blocks.unshift(lastBlock); __private.popLastBlock(modules.blockchain.getLastBlock(), function (err, newLastBlock) { if(err){ library.logger.error('error removing block', block); library.logger.error('error removing block', err); } library.logger.debug('removing block', block); next(err); }); }, function (err) { // reset the last receipt and try to rebuild now self.lastReceipt(new Date()); return cb(err, blocks); } );
async.whilst( function () { return count < 10000000; }, function (callback) { count++; client.sendRequest('/test1', null, function (err, response) { console.log(err); console.log(response); console.log(count); if (err) return callback(err); callback(null); }); }, function (err, n) { console.log('finished'); console.log(err); } );
getPathNodes(callback) { let retval = [], node = this; async.whilst( () => { return node.getParentIds().length > 0; }, callback => { Node.loadById(node.getParentIds()[0], (err, parentNode) => { retval.push(parentNode); node = parentNode; callback(err); }); }, err => { return callback(err, retval); } ); }
async.whilst((callback) => { callback(null, this._queue.paused); }, (callback) => { setTimeout(() => callback(null), 500); }, (err) => { request.post({ url: `${this.options.baseURL}/session`, headers: this.getHeaders(), json: { provider: {providerId: providerId} }, resolveWithFullResponse: true }).then((res) => { const myAccount = /myacinfo=.+?;/.exec(this._cookies); //extract the current acc info cookie const cookies = res.headers['set-cookie']; const itCtx = /itctx=.+?;/.exec(cookies); if (itCtx == null || itCtx.length == 0) { return callback(new Error('No itCtx cookie :( Apple probably changed the login process')); } this._cookies = `${myAccount[0]} ${itCtx[0]}`; callback(null); }).catch((err) => { callback(err); }); });
/** * Returns the next date and time that the market will be open. * @author Torrey Leonard <https://github.com/Ladinn> * @returns {Promise.<Date>} */ getNextOpen() { const _this = this; return new Promise((resolve, reject) => { let next = null; let days = moment().isAfter(_this.getOpen()) ? 1 : 0; async.whilst( () => { return next === null; }, callback => { let newDate = moment().add(days, 'days'); _this.getHoursOn(newDate.toDate()).then(hours => { if (hours.isOpen) next = hours.open; callback(); }).catch(error => reject(new LibraryError(error))); }, () => { resolve(next); }) }) }
async.whilst( function () { return retry > 0 && flag;