async.mapSeries(options.repos, loadService, function(err, services) { // Remove any service that doesnt have an assets child services = _.filter(services, function(service) { return service.assets; }); async.mapSeries(services, function(service, cb) { doBuild(service, options, function(err) { createAssetList(service, options.minify, options.tagFilter, cb); }); }, function(err, assetList) { var staticAssets = {}; assetList.forEach(function(asset) { _.forOwn(asset, function(value, key) { staticAssets[key] = value; }); }); // Dedupe removeDuplicates(staticAssets, function(err, staticAssets) { // Now go and minify if (options.minify) { getLastCommitForAssets(staticAssets, function(err, staticAssets) { minify(staticAssets, function(err, staticAssets) { createAssetHtmlFiles(staticAssets, next); }); }); } else { createAssetHtmlFiles(staticAssets, next); } }); }); });
fs.readdir(path, function (err, files) { if (err) return callback(err) var space = new Space() var paths = _.map(files, function (value){return path + value}) async.mapSeries(paths, fileStats, function(err, stats){ if (err) return callback(err) // stats is now an array of stats for each file for (var i in files) { space.set(files[i], stats[i]) } callback(false, space) }) })
function(userId, groupId, cb) { async.mapSeries( array, function(obj, cb) { obj._userId = userId; obj._groupId = groupId; dataBroker.addDatum(obj, function(err){ if (err != null) { if (err.errorCode === 'duplicate') { duplicates.push(count); err = null; } else { err.dataIndex = count; } } ++count; cb(err); }); }, cb ); }
function(mid, callback){ var pubDate = kmaTimelib.getKoreaDateObj(mid.pubDate); log.info('mid forecast : ', mid.regId, id, mid.pubDate, mid.data.length); async.mapSeries(mid.data, function(item, cbMidData){ var fcsDate = kmaTimelib.getKoreaDateObj(item.date + item.time); var newItem = {regId: mid.regId, pubDate: pubDate, fcsDate: fcsDate, data: item}; modelKmaTownMidForecast.update({regId:mid.regId, fcsDate: fcsDate}, newItem, {upsert:true}, function(err){ if(err){ log.info('Failed to update Mid Forecast Data : ', newItem); } //log.info('save mid forecast : ', JSON.stringify(newItem)); cbMidData(null); }); }, function(err, res){ log.info('convert Mid Forecast : ', mid.regId); return callback(null); } ); },
KmaStnInfo.find().exec(function (err, kmaStnList) { if (err) { return callback(err); } async.mapSeries(kmaStnList, function (stnInfo, mCallback) { self._updateRnsHitRate(stnInfo, function (err, result) { if (err) { return mCallback(err); } mCallback(err, result); }); }, function (err, results) { if (err) { return callback(err); } callback(err, results); } ); });
self.collection.fetch({success:function(){ var async = require('async'); async.mapSeries(self.collection.models,function(model,cb){ var column = model.attributes; if(self._canDisplayColumn(column)){ var type = column['type']; if(typeof type == 'undefined' || type == null){ type = 'text'; } var element = new openbiz.elements.columns[type]; element.getConfig(self,column,self._getRecordActions(),function(field){ cb(null,field); }); } },function(err,results){ if(!err){ callback(results); }else{ callback([]); } }) },error:function(){
function getImages (images) { const stdio = { stdout: through(), stderr: through() }; async.mapSeries(images, function (image, done) { console.log(c.green('pulling docker image'), image); const name = `${ image.name }${ image.tag ? (':' + image.tag) : ''}`; const ps = spawn('docker', ['pull', name], { }); ps.on('exit', function (code) { if (code !== 0) { console.warn('failed to pull image'); } done(); }); ps.stdout.pipe(stdio.stdout); ps.stderr.pipe(stdio.stderr); }); return stdio; }
/** * 编译模板 * * @return {[type]} [return description] */ function compile(tasks) { var defer = Q.defer(); async.mapSeries(tasks, function (task, cb) { readFile(task).then(function (file) { try { var render = etpl.compile(file); caches[task] = render; cb(null, render); } catch (e) { cb(e); } }, function (err) { cb(err); }); }, function (err, result) { err ? defer.reject(err) : defer.resolve(result); }); return defer.promise; }
var readFiles = function(cb) { var minifyFile = function(file, cb) { console.log("minified", file); var result = UglifyJS.minify(file); cb(null, new Buffer(result.code)); }; var readFile = function(file, cb) { var minName = file.replace(/\\*.js$/, ".min.js"); fs.exists(minName, function(is) { if (is){ fs.readFile(minName, cb); } else{ minifyFile(file, cb); } }); }; async.mapSeries(files, readFile, cb); };
Apartment.find(filters).populate(['country', 'province']).exec(function(err, data) { if (err) { console.log(err); res.status(500).send(err); return false; } async.mapSeries(data, function(apartment_block, next) { apartment_block.availableApartmentsFor(search.from_timestamp, search.to_timestamp, search.people, function(_apartments) { if (_apartments.apartments.length > 0) { var lower = 0; _.each(_apartments.apartments, function(_ap) { if (lower === 0 || _ap.stay_total < lower) { lower = _ap.stay_total; } }); apartment_block.stay_total = lower; apartment_block.availableApartments = _apartments; next(null, apartment_block); } else { next(); } }); }, function(err, data) { doRender(_.compact(data)); }) });
Environment.prototype.createRepos = function(config, callback) { var self = this; async.mapSeries(config, function(conf, callback) { self.createFolder(conf.path, function() { self.initFolder({ bare: !!conf.bare, path: conf.path }, function() { if (conf.initCommits) { async.timesSeries(conf.initCommits, function(x, callback) { self.createTestFile(conf.path + '/testy' + x, function() { self.backgroundAction('POST', self.url + '/api/commit', { path: conf.path, message: 'Init Commit ' + x, files: [{ name: 'testy' + x }] }, callback); }); }, callback); } else { callback(); } }); }); }, callback); }
userUtils.loginUser(demouser1.username, demouser1.password, function (err, agent) { if (err) { callback(err, agent); } else { async.mapSeries(projectsData, function (projectData, cb) { async.mapSeries(foldersData, function (folderData, cb) { itemUtils.updateItemMetadata(true, agent, projectData.handle, folderData.name, folderData.metadata, function (err, res) { cb(err, res); }); }, function (err, results) { cb(err, results); }); }, function (err, results) { if (isNull(err)) { unitUtils.endLoad(self, function (err, results) { callback(err, results); }); } else { Logger.log("error", "Error adding metadata to folders in addMetadataToFolders.Unit."); Logger.log("error", err); Logger.log("error", results); callback(err, results); } }); } });
}, function (err, nics) { if (err) { return callback(err); } return async.mapSeries(nics, function (nic, next) { if (nic.state === nicState) { next(); } self.updateNic(nic.mac, { state: nicState }, function (err2) { if (err2) { self.log.error(err2, 'Could not update NIC %s for VM %s', nic.mac, vmUuid); } else { self.log.info('NIC %s updated for VM %s', nic.mac, vmUuid); } return next(err2); }); }, callback); });
module.exports = function (callback) { var packages = { server: path.join(paths.ROOT, 'package.json'), client: path.join(paths.CLIENT, 'package.json'), }; async.mapSeries(packages, lintDependencies, function (err, results) { log.info('\n\n#### NPM UPDATES AVAILABLES ###'); log.info('\n# SERVER'); Object.keys(results.server).forEach(function (dep) { log.info(dep + ': ' + results.server[dep].required + ' -> ' + results.server[dep].stable); }); log.info('\n# CLIENT'); Object.keys(results.client).forEach(function (dep) { log.info(dep + ': ' + results.client[dep].required + ' -> ' + results.client[dep].stable); }); log.info('\n'); callback(null); }); };
afterEach(function(done) { var arrToRemove = memberRelations.concat([ user1, user2, user3, user4, board1, board2, boardCreator1, boardCreator2 ]); async.mapSeries(arrToRemove, function(item, callback) { item.remove(function(err, itemRemoved) { if (err) callback(err, null); else callback(null, itemRemoved); }); }, function(err, results) { if (err) throw err; done(); }); });
}, function(err, transformed){ console.log("Fini le parsing", transformed); async.mapSeries(arr, function(i, callback){ monfichier.webServiceExterne(function(error, result){ console.log(result, " ", i); callback(null, i*10); }); }, function(err, transformed){ console.log("WebServiceExterne fini", transformed); async.mapSeries(arr, function(i, callback){ monfichier.maDB(function(error, result){ console.log(result, " ", i); callback(null, i*200); }); }, function(err, transformed){ console.log("maDB fini", transformed); }); }); });
function _resolve_reference_to_object(obj,callback) { async.mapSeries( obj.references, // iterator function (item, inner_callback) { self.read(item.nodeId, function (err, transformed_obj) { inner_callback(err, transformed_obj); }); }, function (err, result) { obj.references = _.zip(obj.references,result).map(function(pair){ var r = pair[0]; var o = pair[1]; return { referenceType: r.referenceTypeId.displayText(), object: o }; }); callback(err, obj); } ); }
exports.getBusPredictionSeries = function getBusPredictionSeries(arr, done) { var self = this; async.mapSeries(arr, function(item, cb) { setTimeout(function() { self.getBusPrediction(item, function(err, res) { if (err) { return cb(err); } else { return cb(null, {name: item, data: res}) } }) }, 250); }, function(err, mappedData) { if (err) { return done(err); } else { return done(null, mappedData); } }); }
topicSystem.topic.findPendingTopicsForUser(user, message, function (err, aTopics) { if (err) { console.log(err); } // Flash topics with pre-set list if (!_.isEmpty(options.aTopics)) { debug.verbose("Flashed topics (directReply, respond or topicRedirect)"); } aTopics = !_.isEmpty(options.aTopics) ? options.aTopics : aTopics; debug.info("Topics to check", aTopics.map(function(x) { return x.name })); // We use map here because it will bail on error. // The error is our escape hatch when we have a reply WITH data. async.mapSeries( aTopics, topicItorHandle(topicSystem, message, user, localOptions), function topicCompleteHandle(err2, results) { if (err2) { console.log(err2); } // Remove the empty topics, and flatten the array down. var matches = _.flatten(_.filter(results, function (e) { return e; })); // TODO - This sort should happen in the process sort logic. // Lets sort the matches by qType.length matches = matches.sort(function(a, b) { return a.trigger.qType.length < b.trigger.qType.length; }); // Was `eachSeries` async.mapSeries(matches, matchItorHandle(user, message, localOptions), afterHandle(user, callback)); } ); });
var glueDocs = function (hits, q, callbackX) { async.mapSeries(hits, function (item, callback) { options.indexes.get('DOCUMENT○' + item.id + '○', function (err, value) { item.document = value; var terms = q.query['*']; if (q.query[q.teaser]) terms = q.query[q.teaser]; if (q.teaser && item.document[q.teaser]) { try { item.document.teaser = scontext(item.document[q.teaser], terms, 400, function hi (string) { return '<span class="sc-em">' + string + '</span>'; }); } catch (e) { log.warn('error with teaser generation: ' + e); } } callback(null, item); }); }, function (err, result) { return callbackX(result); }); };
).then((items) => { console.log(''); const toMove = items .filter((fileObject) => { if (!fileObject.willMove) { console.log('Skipping', fileObject.file); return false; } return true; }); let moveCount = 0; if (!toMove.length) { console.log(''); console.log('-- no files to move --'); } else { async.mapSeries( toMove, (fileObject, callback) => { Filesystem.moveFrom( fileObject.file, fileObject.path, fileObject.type.destFolder ).then(() => { moveCount += 1; console.log(`${moveCount}/${toMove.length} done`); callback(null, moveCount); }, (err) => { callback(err, null); }); }, (err, results) => { console.log(''); console.log('Done all moves'); } ); } });
function(childProcess, jbpmTopLevelTasks, callback) { var childProcesInsIds = []; for (var i in childProcess.list) { var log = childProcess.list[i]; for (var x in log) { childProcesInsIds.push(log[x].processInstanceId); } } async.mapSeries(childProcesInsIds, function( childProcesInsId, itemCallback ) { var jbpmURI = init.getJBPMServiceProps()['jBPMServiceURI'] + '/rest/task/query?processInstanceId=' + childProcesInsId; console.log('calling jbpm: ', jbpmURI); jBPMClient.get(jbpmURI, function(err, req, res, obj) { if(err) { console.log("An error ocurred:", err); itemCallback(err); } else { itemCallback(null, obj); } }); }, function(err, childTasks) { if( err ) { console.log('error in foreach mission loop', err); response.json(400, err); } else { for (var i in childTasks) { jbpmTopLevelTasks.list.push.apply(jbpmTopLevelTasks.list, childTasks[i].list); } callback(null, jbpmTopLevelTasks); } }); }
var g = new Glob(pattern, {cwd: base, root: base}, function (er, files) { var statCache = g.statCache; async.mapSeries(files, function(input, done) { var statInput = statCache[input] || (statCache[input] = fs.statSync(input)); if(statInput.isDirectory()) { return done(); } var output = join(dest,relative(base,input)); try { if(fs.statSync(output).mtime.getTime() === statInput.mtime.getTime()) { debug('Ignore (no changes) : "%s"',relative(base,input)); return done(); } } catch(e) {}; debug("copy %s -> %s", relative(base,input), relative(base,output)); async.series([ // Copy file function(done) { copyfile(input, output).then(lcb(done)); }, // Update copied file mtime function(done) { debug('Copy mtime') fs.utimes(output, statInput.atime, statInput.mtime, done); } ], done); },function(err, result) { debug('DONE'); }) });
walker(main_file, walker.OPTIONS.BROWSER, function (err, nodes) { if(err){return done(err);} var module_names = Object.keys(nodes).filter(function(name){ return nodes[name].foreign }).filter(function(name){ return !util.isTarball(dependencies[name]); }); module_names.length && console.log(" dependencies:\n" + module_names.map(function(name){return " |-- " + name}).join("\n")); async.mapSeries(module_names, function(module_name, done){ var version = dependencies[module_name] || "latest"; console.log("\n"); self.migrate(module_name, version, done); }, function(err){ if(err){return done(err);} var cwd = process.cwd(); async.series([ function(done){ process.chdir( path.join(moduleDir, "package") ); done(); }, function(done){ var deps = {}; module_names.forEach(function(name){ deps[name] = dependencies[name]; }) util.cortexInstall(deps, done); }, function(done){ util.cortexBuild(done); }, function(done){ util.cortexPublish(done); } ], done); }); });
router.get('/', function(req, res) { var phrase = 'may the force be with you'; var key = "TZlKw4gd1qFQhA2CbMLa"; var urlBase = "http://thesaurus.altervista.org/service.php?language=en_US&output=json&key=" + key + "&word="; var stuff = phrase.split(' '); async.mapSeries(stuff, function (word, next) { console.log('word', word); request(urlBase + word, function (error, response, body) { if (error) return console.error(error); var list = JSON.parse(body).response; next(null, { word: word, list: list }); }) }, function (error, results) { console.log('results', results); var counts = _.map(_.compact(results), function (result) { console.log('result', result); var allwords = _.unique(_.reduce(result.list, function (all, response) { console.log('response', response); var syns = response.list.synonyms.split('|'); return all.concat(syns); }, [ ])); console.log('allwords', allwords); return { word: result.word, count: allwords.length }; }); var sorted = _.sortBy(counts, function (result) { return 0 - result.count; }); console.log('the winner is', sorted[0].word, 'with', sorted[0].count, 'synonyms'); } ); });
PopularHashtag.getTags(isTest, function getTweetsFromHashtagList(err, hashtags) { if (err) { return callback(err); } var startDate = isTest ? 0 : getDateTimeInMilSeconds(-2); async.mapSeries( hashtags, function getTweetIdForEachHashtag(hashtag, doneForAllHashtags) { HashtagToTweet.getTweetId(hashtag.name, startDate, getDateTimeInMilSeconds(0), // endDate = today. function getTweetsFromTweetIdList(err, tweetIdList) { if (err) { return callback(err); } async.mapSeries( tweetIdList, function getTweetForEachTweetId(tweetId, postProcess) { Tweet.getTweetById( tweetId.tweetId, postProcess); }, function postProcess(err, tweets) { doneForAllHashtags(null, { hashtag: hashtag.name, tweets: tweets }); }); } ); }, function doneForAllHashtags(err, hashTagsToTweetsMapping) { //console.log(util.inspect(hashTagsToTweetsMapping, false, null)); getHashtagsToTweetsMapping(null, hashTagsToTweetsMapping); } ); });
this.pgUtils.getMetadata((err, metadata) => { if (err) { return callback(err); } debug('runMigrations: Current version is ' + metadata.version); if (metadata.version < CURRENT_DATABASE_VERSION) { debug('runMigrations: Desired version is ' + CURRENT_DATABASE_VERSION); // We need to run migrations const migrationSteps = []; for (let i = metadata.version + 1; i <= CURRENT_DATABASE_VERSION; ++i) { migrationSteps.push(i); } async.mapSeries(migrationSteps, (stepNumber, callback) => { const migrationSqlFile = path.join(__dirname, 'schemas', `migration-${stepNumber}.sql`); instance.pgUtils.runSql(migrationSqlFile, (err) => { if (err) { debug(`runMigrations: Migration ${stepNumber} failed.`); return callback(err); } metadata.version = stepNumber; instance.pgUtils.setMetadata(metadata, callback); if (stepNumber === 3) { this.populateSubscriptionApiGroup(); } }); }, (err) => { if (err) { return callback(err); } debug('runMigrations successfully finished.'); return callback(null); }); } else { debug('runMigrations: No migrations needed.'); return callback(null); } });
TownRss.prototype.saveShortRssNewForm = function(index, newData, callback){ var pubDate = kmaTimelib.getKoreaDateObj(newData.pubDate); log.info('KMA Town S-RSS> pubDate :', pubDate.toString()); //log.info('KMA Town S-RSS> db find :', coord); try{ async.mapSeries(newData.shortData, function(item, cb){ var fcsDate = kmaTimelib.getKoreaDateObj(item.date); var newItem = {mCoord: newData.mCoord, pubDate: pubDate, fcsDate: fcsDate, shortData: item}; log.debug('KMA Town S-RSS> item : ', JSON.stringify(newItem)); modelKmaTownShortRss.update({mCoord: newData.mCoord, fcsDate: fcsDate}, newItem, {upsert:true}, function(err){ if(err){ log.error('KMA Town S-RSS> Fail to update current item'); log.info(JSON.stringify(newItem)); return cb(); } cb(); }); }, function(err){ log.debug('KMA Town S-RSS> finished to save town.short.rss data'); callback(err); } ); }catch(e){ if(callback){ callback(e); } else { log.error(e); } } };
// Each batch adds a new row. function addRows(err, _batches) { if (err) { return end(err); } batches = _batches; batchTables = batches.map(function(batch) { return batch.table(table.name); }); // Put to the same key in each batch. var key = uniqueName('key'); async.mapSeries(batchTables, function(batchTable, cb) { // Put different value in each batch. var value = uniqueName('value'); batchTable.put(ctx, key, value, function(err) { if (err) { return cb(err); } return cb(null, [{key: key, value: value}]); }); }, assertBatchesSeeCorrectRows); }
client.query("BEGIN", function(err){ if (err){ _rollback(client, done); reject(err); } var mapIterator = function(queryObj, mapCallback){ client.query(queryObj.queryString, queryObj.argumentArray, mapCallback); }; async.mapSeries(queryObjArr, mapIterator, function(err, results){ if (err){ _rollback(client, done); reject(err); } client.query("COMMIT", function(err){ if (err){ _rollback(client, done); reject(err); } }); done(); resolve(results); }); });