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(
78
165
13
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);
37
97
7
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!');
23
57
8
+ 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) => {
1
6
11
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)
1
0
1
+ 21 other calls in file
GitHub: khrome/peer-pressure
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){
0
0
2
+ 5 other calls in file
async.parallel is the most popular function in async (1226 examples)