How to use the eachOfLimit function from async

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

98
99
100
101
102
103
104
105
106
107
if (err) {
  console.error(err);
  return next('STOP');
}
if (movies && movies.length) {
  async.eachOfLimit(
    movies,
    1,
    function(movie, key, callback) {
      CP_get.movies(
fork icon78
star icon165
watch icon13

30
31
32
33
34
35
36
37
38
39

function read_object_files(files, opts, callback) {
  opts = opts || {};
  opts = _.defaults(opts, { savePoints: false, limit: 4 });
  var results = [];
  async.eachOfLimit(files, opts.limit, function (file, index, cb) {
    STK.fs.loadDelimited(file, { delimiter: ' ', header: false, skipEmptyLines: true, dynamicTyping: false }, function(err, records) {
      var result;
      if (err) {
        console.error('Error parsing object file ' + file, err);
fork icon37
star icon97
watch icon7

46
47
48
49
50
51
52
53
54
55

try {
  const rawPeople = JSON.parse(fs.readFileSync(filePath).toString());
  log.info(`Total ${rawPeople.length} people`);

  async.eachOfLimit(rawPeople, 50, getInsertCandidateFunc(), (err) => {
    if (err) {
      log.error(err);
    } else {
      log.info('Finished!');
fork icon23
star icon57
watch icon8

+ 3 other calls in file

53
54
55
56
57
58
59
60
61
62
console.log(data);
    query('INSERT INTO ' + searchTable + ' SET ?', data)
  })
}
static loopOnTablesToIndex(tablesFields, next) {
  async.eachOfLimit(tablesFields, 1,
    (fields, table, callback) => {
    SearchIndexer.createIndexBulk(table, fields);
    callback();
  }, (err) => {
fork icon1
star icon6
watch icon11

88
89
90
91
92
93
94
95
96
97
    })
  })
}
async eachOfLimit(coll, limit, iteratee) {    
  return new Promise(async (resolve, reject) => { 
    async.eachOfLimit(coll, limit, iteratee, (err, res) => {
      if (err) { 
        reject(err)
      } else {
        resolve(res)
fork icon1
star icon0
watch icon1

+ 21 other calls in file

110
111
112
113
114
115
116
117
118
119
        }]));
    });
}),
cleanup : unpromisify(function(cb){
    var browsers = Object.keys(browserInstances).map((key)=>browserInstances[key]);
    asynk.eachOfLimit(browsers, browsers.length, function(browser, index, done){
        var attempts = 0;
        var maxAttempts = 2;
        var interval = 1000;
        var ensureShutdown = function(cb){
fork icon0
star icon0
watch icon2

+ 5 other calls in file