export function optLifecycles(comps: ILifeCycle[], method: string, app: Application, cb: (err?: Error) => void, arg2 ?: any) { let i = 0; async.forEachSeries(comps, function (comp, done) { i++; if (typeof (comp as any)[method] === 'function') { (comp as any)[method](app , done , arg2); } else { done(); } }, function (err: Error) { if (err) { if (typeof err === 'string') { logger.error('fail to operate lifecycle, method: %s, err: %j', method, err); } else { logger.error('fail to operate lifecycle, method: %s, err: %j', method, err.stack); } } utils.invokeCallback(cb, err); }); }
async.forEachSeries(cmethods, function (method, cb) { method(cb); transactionLogger.info('[%s]:[%s] condition is executed.', name, cnames[i]); let j = 0; retry--; async.forEachSeries(dmethods, function (method, cb) { method(cb); transactionLogger.info('[%s]:[%s] handler is executed.', name, dnames[j]);
iterateDirectory(directory, remoteFolder, callback) { fs.readdir(directory, (err, list) => { if (err) { return callback(err); } if (list.length === 0) { return callback(); } async.forEachSeries(list, (item, callback) => { let itemPath = `${directory}/${item}`, remoteFile = itemPath.replace(directory, remoteFolder); this.checkFile(itemPath, remoteFile, callback); }, err => { callback(err); }); }); }
mongoose.model("row").find({CodeParentRow: parent.CodeRow}).isactive().sort('IndexRow').exec(function(err, children) { if (err) return callback(err); if (!_.isEmpty(children)) { async.forEachSeries(children, function(item, cb) { self.RebuildTree(item, parent.rgt, CodeUser, function() { parent.rgt = item.rgt + 1; parent.userSave(CodeUser,cb); }); }, function(err) { callback(); }); } else { parent.userSave(CodeUser,callback); } })
static buildMarkdownTree(node, prefix, options, callback) { node.getChildren({ remote: options.remote, }, (err, nodes) => { async.forEachSeries(nodes, (node, callback) => { let name = node.getName(); if (node.getLabels().indexOf('enc') !== -1 && options.decrypt) { name = Utils.decryptString(node.getName(), options.password, options.algorithm); } if (options['show-ids']) { name += ` (${node.getId()})`; } Logger.info(`${prefix}- ${name}`); if (node.isFolder() || options.showAssets) { return TreeCommand.buildMarkdownTree(node, `${prefix} `, options, callback); } callback(); }, err => { callback(err); }); }); }
restore(node, callback) { this.restoreNode(node, (err, result) => { if (err) { return callback(err); } if (result.success && node.isFolder()) { return node.getChildren({ remote: this.options.remote, }, (err, children) => { async.forEachSeries(children, (child, callback) => { this.restore(child, (err, result) => { return callback(err, result); }); }, err => { return callback(err); }); }); } return callback(null, result); }); }
function deleteApnDevices(devices, callback) { log.info('Deleting Apn devices'); log.debug('Deleting Apn devices', devices); async.forEachSeries(devices, function(device, done) { Identity.update({'devices.apn': {$in: [device]}}, {$pull: {'devices.apn': device}}, function(err) { if (err) { return done(err); } return done(); }); }, function(err) { if (err) { return callback(err); } callback(null); }); }
async.forEachSeries(comps, function(comp, done){ i++; if(typeof comp[method] === 'function'){ comp[method](done); }else if(typeof done === 'function'){ done(); }else{ console.log("我需要执行什么东西吗"); } },function(err){ if(err){ console.log("method:"+method+"出错了:",err); } utils.invokeCallback(cb, err) });
async.forEachSeries(smsTargets, function(destination, done) {
async.forEachSeries(args, (localPath, callback) => { localPath = path.resolve(localPath);
remote: this.options.remote, }, (err, children) => { async.forEachSeries(children, (child, callback) => { if (child.isFolder()) { return this.trash(child, callback);
export function optLifecycles(comps: ILifeCycle[], method: string, app: Application, cb: (err?: Error) => void, arg2 ?: any) { let i = 0; async.forEachSeries(comps, function (comp, done) { i++; if (typeof (comp as any)[method] === 'function') { (comp as any)[method](app , done , arg2); } else { done(); } }, function (err: Error) { if (err) { if (typeof err === 'string') { logger.error('fail to operate lifecycle, method: %s, err: %j', method, err); } else { logger.error('fail to operate lifecycle, method: %s, err: %j', method, err.stack); } } utils.invokeCallback(cb, err); }); }
/** * Apply command to loaded components. * This method would invoke the component {method} in series. * Any component {method} return err, it would return err directly. * * @param {Array} comps loaded component list * @param {String} method component lifecycle method name, such as: start, stop * @param {Function} cb */ export function optComponents(comps: IComponent[], method: string, cb: (err?: Error) => void) { let i = 0; async.forEachSeries(comps, function (comp, done) { i++; if (typeof (comp as any)[method] === 'function') { (comp as any)[method](done); } else { done(); } }, function (err: Error) { if (err) { if (typeof err === 'string') { logger.error('fail to operate component, method: %s, err: %j', method, err); } else { logger.error('fail to operate component, method: %s, err: %j', method, err.stack); } } utils.invokeCallback(cb, err); }); }
/** * Apply command to loaded components. * This method would invoke the component {method} in series. * Any component {method} return err, it would return err directly. * * @param {Array} comps loaded component list * @param {String} method component lifecycle method name, such as: start, stop * @param {Function} cb */ export function optComponents(comps: IComponent[], method: string, cb: (err?: Error) => void) { let i = 0; async.forEachSeries(comps, function (comp, done) { i++; if (typeof (comp as any)[method] === 'function') { (comp as any)[method](done); } else { done(); } }, function (err: Error) { if (err) { if (typeof err === 'string') { logger.error('fail to operate component, method: %s, err: %j', method, err); } else { logger.error('fail to operate component, method: %s, err: %j', method, err.stack); } } utils.invokeCallback(cb, err); }); }
async.forEachSeries(cmethods, function (method, cb) { method(cb); transactionLogger.info('[%s]:[%s] condition is executed.', name, cnames[i]); let j = 0; retry--; async.forEachSeries(dmethods, function (method, cb) { method(cb); transactionLogger.info('[%s]:[%s] handler is executed.', name, dnames[j]);