How to use the whilst function from async

Find comprehensive JavaScript async.whilst code examples handpicked from public code repositorys.

68
69
70
71
72
73
74
75
76
77
let resources = ["Basic", "Questionnaire", "Parameters"]
const promises = []
for(let resource of resources) {
  promises.push(new Promise((resolve1) => {
    let params = {}
    async.whilst(
      (callback) => {
        return callback(null, nxturl !== false)
      },
      (callback) => {
fork icon25
star icon26
watch icon8

+ 10 other calls in file

14
15
16
17
18
19
20
21
22
23
    * @param {Function} cb - callback
    * @returns {undefined}
*/
function putBulkObjectVersions(metadata, bucketName, objName, objVal, params, versionNb, timestamp, logger, cb) {
    let count = 0;
    return async.whilst(
        () => count < versionNb,
        cbIterator => {
            count++;
            const lastModified = new Date(timestamp + count).toISOString();
fork icon17
star icon13
watch icon56

6001
6002
6003
6004
6005
6006
6007
6008
6009
6010
* callback. Invoked with (err, [results]);
* @returns undefined
* @example
*
* var count = 0;
* async.whilst(
*     function() { return count < 5; },
*     function(callback) {
*         count++;
*         setTimeout(function() {
fork icon0
star icon2
watch icon1

224
225
226
227
228
229
230
231
232
233
    names = Object.keys(this.stores),
    self = this,
    response,
    mergeObjs = [];

async.whilst(function () {
  return typeof response === 'undefined' && current < names.length;
}, function (next) {
  var store = self.stores[names[current]];
  current++;
fork icon0
star icon0
watch icon2

796
797
798
799
800
801
802
803
804
    }
};

async.doWhilst = function (iterator, test, callback) {
    var calls = 0;
    return async.whilst(function() {
        return ++calls <= 1 || test.apply(this, arguments);
    }, iterator, callback);
};
fork icon0
star icon0
watch icon1

+ 43 other calls in file