function multipleOpen (filename, N, callback) { async.whilst( function () { return i < N; } , function (cb) { fs.open(filename, 'r', function (err, fd) { i += 1; if (fd) { fds.push(fd); } return cb(err); }); } , callback); }
const filterFn = () => { async.filter([1, 2, 3, 4, 5], function (item, cb) { square(item, (err, res) => { cb(err, res > 10); }); }, done); }
async.each(["DocRow","Div","Period","Tag","AllCols"],function(HName,cb){ var H = require(HPath+HName); H.get(function(err,In){ self.Help[HName] = In; return cb(err); }) },done);
mongoose.model("docrow").find({CodeDoc:CodeDoc,IsExpandTree:true},"-_id CodeRow CodeBiztranObj IsExpandTree").sort({IndexRow:1}).isactive().lean().exec(function(err,Rows){ if (err) return done(err); if (_.isEmpty(Rows)) return done(null,Result); var Roots = _.map(Rows,"CodeRow"); Roots.forEach(function(R){Result[R] = [];}); async.each(Roots,function(CodeRow,cb){ self.LoadRoot(CodeRow,function(err,Rows){ Result[CodeRow] = Rows; return cb(err); }) },function(err){ return done(err,Result); }); })
async.parallel([ function(cb) { async.each(obj.sections, function(section, cb) { run(require("./teaserSection"), section, cb); }, cb); }, function(cb) { async.each(Object.keys(obj.imgUrls), function(key, cb) { assert(/^http(s)?:\/\/.+\.[a-z]+$/.test(obj.imgUrls[key]), "Unexpected teaser image URL format"); cb(); }, cb); } ], done);
async.each(["Css","Js","Templates"],function(Type,cb){ self[Type](function(err,Cont){ Content[Type] = Cont; return cb(); }) },function(err){ fs.writeFileSync(__base+"static/build/index.html",[Content.Css,Content.Js,Content.Templates].join("\n\n")); console.log("BUILD is done"); done && done(); })
self._tablesList(function(err,List){ async.each(List,function(TableName,cb){ self._columnList(TableName,function(err,Сolumns){ Result[TableName] = Сolumns; return cb(err); }) },function(err){ return done(err,Result); }); })
async.each(obj.sortOptions, function(key, cb) { assert(typeof key == "string", "Unexpected teaser type"); assert(/^(relevance|popularity|price|discount|time)$/.test(key), "Unexpected sort option: " + key); cb(); }, done);
// TODO: use a good bloom filter lib // filtering out the peers likely already reached async.each(peers, function (peer, cb) { if(!modules.system.isMyself(peer)){ return self.requestFromPeer(peer, options, cb); } else{ return cb(); } }, cb);
const rejectFn = () => { async.reject([1, 2, 3, 4, 5], function (item, cb) { square(item, (err, res) => { cb(err, res > 10); }); }, done); }
loadFiles(files, renderOptions, done) { this.beforeLoad(files); let rawContent = ""; async.each(files, (file, cb) => { this.fileLoader(file, renderOptions, (err, res) => { rawContent += res; cb(err); }); }, (err) => { done(err, rawContent); }); }
async.each(Object.keys(obj.imgUrls), function(key, cb) { assert(/^http(s)?:\/\/.+\.[a-z]+$/.test(obj.imgUrls[key]), "Unexpected teaser image URL format"); cb(); }, done);