//-----------------------------------
 // 4. filter the results.
 //-----------------------------------
 function (keys, callback) {
   if (regexp === null) {
     callback(null, keys);
     return;
   }
   async.filter(keys, function(key, cback) {
     cback(regexp.test(key));
   }, function(results) {
     callback(null, results);
   });
 }
Example #2
0
 fs.readdir(folder, function (err, files) {
   if (err) {
     next(err);
   }
   // tries to create an app for each folder.
   async.filter(files, function (file, next) {
     appLoader.add(folder + file, expressApp, next);
   }, function (err, result) {
     next(err, result);
   });
 });
Example #3
0
  step(){
    async.filter(this.particles, (a, callback) => {
      callback(a.step())
    }, particles => {
      this.particles = particles
    })

    this.updateGrid()

    this.theta += (1.0-2.0*Math.random())*this.particleConfig.angleStp
  }
Example #4
0
		}, function(err, messages) {
			async.filter(messages, function(message, callback) {
				callback(!!message);
			}, function (messages) {
				var messageResult = messages.join('\n');
				var returnVal = {
					text: messageResult
				};
				return res.json(returnVal);
			});
		});
Example #5
0
					function stepFilterWinnersByName(callback) {
						//console.log('stepFilterWinnersByName', winnersByName.length);
						if (!found || winnersByName.length == 0) return callback();
						//If found someone by UTC offset then add only countries without offset info
						async.filter(winnersByName, function(place, next) {
							return next(place.offset_raw === null);
						}, function(results) {
							winnersByName = results;
							callback();
						});
					},
Example #6
0
					fs.readdir(buildPath, function(e, files){
						files = _.map(files, function(file){
							return path.join(buildPath, file);
						});	
						async.filter(files, function(file, done){
							if(!fs.statSync(file).isDirectory()) done(true);
							else fs.stat(path.join(file, 'index.html'), done);
						}, function(todel){
							async.each(todel, fs.remove, cb);
						});
					});
// Returns the avaliable browsers on the current machine.
function getAvailableBrowsers(cb){
  var browsers = browsersForPlatform()
  browsers.forEach(function(b){
    b.protocol = 'browser'
  })
  async.filter(browsers, function(browser, cb){
    browser.supported(cb)
  }, function(available){
    cb(available)
  })
}
Example #8
0
		db.getObjectValues('group:gid', function(err, gids) {
			async.filter(gids, function(gid, next) {
				Groups.isMember(uid, gid, function(err, isMember) {
					next(isMember);
				});
			}, function(gids) {
				async.map(gids, function(gid, next) {
					Groups.get(gid, {}, next);
				}, callback);
			});
		});
Example #9
0
			function(plugins, next) {
				var pluginBasePath = path.join(__dirname, '../node_modules');
				var paths = plugins.map(function(plugin) {
					return path.join(pluginBasePath, plugin);
				});

				// Filter out plugins with invalid paths
				async.filter(paths, file.exists, function(paths) {
					next(null, paths);
				});
			},
Example #10
0
function filterMissingFiles(filepaths, callback) {
	async.filter(filepaths, function (filepath, next) {
		file.exists(path.join(__dirname, '../../node_modules', filepath), function (err, exists) {
			if (!exists) {
				winston.warn('[meta/css] File not found! ' + filepath);
			}

			next(err, exists);
		});
	}, callback);
}
 return new RSVP.Promise((resolve, reject) => {
   async.filter(files, function (file, cb) {
     var fullPath = path.join(base, file);
     fs.stat(fullPath, function (error, stats) {
       if (error) { reject(error); }
       cb(stats.isFile());
     });
   }, function (results) {
     if (typeof callback === 'function') { callback(results); };
     return resolve(results);
   });
 });
Example #12
0
var settings = function (index, callback) {
	
	async.filter(index, require('../_filter')('_settings'), function (_settings_index) {
		yaml.parse(_settings_index[0], function (err, _settings) {
			if (err) throw err;

			callback(null, _settings)
		})
	})

	
}
Example #13
0
function filterBuckets(bucketArray,callback){
  trackProcess("filterBuckets","Filtering buckets only present in ap-southeast-1 Region",bucketArray.gpId,"S");

  async.filter(bucketArray,filterBucketsIterator,function(result){

    if(result){

        callback(null,result);
    }
  });

}
Example #14
0
	var extract_pages=function(done){
		if(data.url.match(/\/following.php/)){
			var nextObjs=[];
			var names=data.html.match(/\"name\"\:\".*?\"/g);
			var fans_count=data.html.match(/\"count\"\:.*?\}/g);
			if(names&&names.length>0){	
				for(var i=0;i<names.length;i++){
					var name=names[i].replace(/\"name\"\:\"(.*?)\"/g,'$1');
					var following=fans_count[i].replace(/\".*?following\"\:(.*?)\,.*?\}/,'$1');
					var follower=fans_count[i].replace(/\".*?follower\"\:(.*?)\}/,'$1');
					var obj={name:name,following:following,follower:follower};
					nextObjs.push(obj);
				}
				names=null;fans_count=null;

				_self.flush=async.queue(function(urls,done){
	 	                       callback(null,[{
				                       handler : 'tencent_people'
		                                       ,urls    : urls.nexts
		                        }],function(){
						done();
					});
				},100);

			
				async.filter(nextObjs,
					function(user,callback){
						redisClient.sadd('tencent',user.name,function(err,res){
							callback(res);
						});
					},
					function(results){
						results.forEach(function(u){
							nexts.push('http://1.t.qq.com/home_userinfo.php?u='+u.name);
							for(var j=1;j<=Math.ceil(parseInt(u.following)/15.0);j++){
								nexts.push('http://1.t.qq.com/asyn/following.php?u='+u.name+'&&time=&page='+j+'&id=&apiType=4&apiHost=http%3A%2F%2Fapi.t.qq.com&_r=1365666653702');
								if(nexts.length>=10){
									_self.flush.push({nexts:nexts});
									nexts=[];
								}else{
									continue;
								}
							}
							_self.flush.push({nexts:nexts});
							nexts=[];
						});
						done();
					}	
				);
			}else done();
		}else	done();

	}
Example #15
0
Command.prototype.parse = function (lines, done) {
  var that = this;
  async.filter(lines, that.funcgrep, function (results) {
      var r = results.join(that.seg.delimiter());
      if (r) {
        r += that.seg.delimiter();
      }
      that.push(r);
      done();
    }
  );
}
Example #16
0
			fstack.ents(path, function(err, ents) {
				if (err) {
					return callback(err);
				}
				async.filter(ents, function(ent, next) {
					fs.stat(fstack.join(path, ent), function(err, stat) {
						next(!stat.isDirectory());
					});
				}, function(files) {
					callback(err, files);
				});
			}, false);
Example #17
0
 function(deps, cb) {
     async.filter(deps, function(dep, cb) {
         switch(dep.type) {
             case "github":
             case "git": 
                 return cb(true);
         }
         return cb(false);
     }, function(filtered) {
         return cb(null, filtered);
     });
 },
Example #18
0
 function(err, new_attendees) {
   //filter out guest accounts
   async.filter(new_attendees, function(att, fcb){
     if (att){
       return fcb(true);
     }
     return fcb(false);
   },function(user_att){
     //call the next function with the list of user-attendees
     cb(err, event, org, place, legacy_attendees, user_att);
   });
 });
Example #19
0
 function(err, new_attendees) {
   //filter out all the guest objects
   async.filter(new_attendees, function(att, fcb){
     if (att){
       return fcb(true);
     }
     return fcb(false);
   },
   function(user_att){
     cb(err, event, org, place, legacy_attendees, user_att);
   });
 }
Example #20
0
 fs.readdir(dir, (err, files) => {
   if (err) {
     res.status(400).json({ errorCode: 'read-dir-failed', error: err });
   } else {
     const absolutePaths = files.map((file) => { return path.join(dir, file) });
     async.filter(absolutePaths, (absolutePath, callback) => {
       fs.stat(absolutePath, (err, stat) => {
         callback(null, !err && stat && stat.isDirectory());
       });
     }, (err, filteredFiles) => res.json(filteredFiles));
   }
 });
Example #21
0
				}, function(err, nid) {
					if (err) {
						return;
					}
					async.filter(followers, function(uid, next) {
						privileges.categories.can('read', results.topic.cid, uid, function(err, canRead) {
							next(!err && canRead);
						});
					}, function(followers){
						notifications.push(nid, followers);
					});
				});
Example #22
0
 function(applications, callback) {
     // Resolve the application paths
     var applicationPaths = applications.map(function(application) {
         return path.join(applicationsPath, application, appName);
     });
     // Filter the applications to determine which ones are associated
     // with the project (should normally be only one). These application
     // will contain a <project>.app file in their root directory.
     async.filter(applicationPaths, fs.exists, function(projectApps) {
         callback(null, projectApps);
     });
 },
  fs.readdir(root, function (err, fragments) {
    if (err) {
      callback(err);
      return;
    }

    async.filter(fragments, function (fragment, cbIsModule) {
      Project.isModule(path.join(root, fragment), cbIsModule);
    }, function (names) {
      callback(null, names);
    });
  });
Example #24
0
    async.eachLimit(list, 1, function(proc, next) {
      // If app name already exists
      if (apps_name.indexOf(proc.name) != -1) {
        // Do restart

        if (action == 'reload') {
          CLI._reloadProcessName(proc.pm2_env.name, 'reloadProcessId', function(err, ret) {
            if (err) printError(err);

            Satan.notifyGod('reload', proc.pm2_env.pm_id);

            // And Remove from array to spy
            apps_name.splice(apps_name.indexOf(proc.name), 1);
            return next();
          });
        } else if (action == 'gracefulReload') {
          CLI._reloadProcessName(proc.pm2_env.name, 'softReloadProcessId', function(err, ret) {
            if (err) printError(err);
            // And Remove from array to spy

            Satan.notifyGod('graceful reload', proc.pm2_env.pm_id);

            apps_name.splice(apps_name.indexOf(proc.name), 1);
            return next();
          });
        } else {
          // Get `env` from appConf by name
          async.filter(appConf, function(app, callback){ callback(app.name == proc.name); }, function(apps){
            var envs = apps.map(function(app){
              return app.env || {};
            });
            // Assigns own enumerable properties of all
            // Notice: if people use the same name in different apps,
            //         duplicated envs will be overrode by the last one
            var env = util._extend.apply(null, envs);

            // Pass `env` option
            CLI._restart(proc.pm2_env.name, env, function(err, ret) {
              if (err) printError(err);

              Satan.notifyGod('restart', proc.pm2_env.pm_id);
              // And Remove from array to spy
              apps_name.splice(apps_name.indexOf(proc.name), 1);
              return next();
            });
          });
        }
      }
      else
        return next();
      return false;
    }, function(err) {
Example #25
0
module.exports = function(paths, callback) {
    async.filter(paths, function(path, cb) {
        fs.lstat(path, function(error, stats) {
            if (error) {
                cb(error);
            } else {
                cb(null, stats.isFile());
            }
        });
    }, function (err, files) {
        callback(err, files);
    });
};
Example #26
0
					function(nextTid, next) {
						var tids = [];
						for(var x=1,numTids=nextTid-1;x<numTids;x++) {
							tids.push(x);
						}
						async.filter(tids, function(tid, next) {
							db.exists('topic:' + tid, function(err, exists) {
								next(exists);
							});
						}, function(tids) {
							next(null, tids);
						});
					},
Example #27
0
		user.getPostIds(uid, start, end, function(err, pids) {
			if (err) {
				return callback(err);
			}

			async.filter(pids, function(pid, next) {
				privileges.posts.can('read', pid, callerUid, function(err, canRead) {
					next(!err && canRead);
				});
			}, function(pids) {
				getPostsFromSet('uid:' + uid + ':posts', pids, callback);
			});
		});
Example #28
0
		db.getSortedSetRevRangeByScore('posts:pid', start, count, Infinity, Date.now() - since, function(err, pids) {
			if(err) {
				return callback(err);
			}

			async.filter(pids, function(pid, next) {
				privileges.posts.can('read', pid, uid, function(err, canRead) {
					next(!err && canRead);
				});
			}, function(pids) {
				Posts.getPostSummaryByPids(pids, true, callback);
			});
		});
Example #29
0
			RDB.zrange('uid:' + uid + ':notifications:unread', 0, -1, function(err, nids) {
				async.filter(nids, function(nid, next) {
					notifications.get(nid, uid, function(notifObj) {
						if (notifObj.uniqueId === uniqueId) {
							next(true);
						} else {
							next(false);
						}
					});
				}, function(nids) {
					callback(null, nids);
				});
			});
Example #30
0
	fs.readdir(PROJECT_DIR, function (err, files) {
		if (err) {
			console.error(err);
			return res.send(500, err);
		}

		async.filter(files, function (file, cb) {
			cb(path.extname(file) == '.xml')
		}, function (results) {
			res.header('Content-Type', 'application/json');
			res.send(JSON.stringify(results));
		});
	});