if (st && st.size === bigFilesize) return done(null) fs.writeFile(bigFilepath, crypto.randomBytes(bigFilesize), done) })
stderr (done) { collect(program.stderr, function (err, chunks) { if (err) return done(err) done(null, Buffer.concat(chunks).toString()) }) }, if (err) return done(err) done(null, Buffer.concat(chunks).toString()) }) }, program.once('exit', function (code, signal) { if (code === 0 && signal === null) { done(null) } else if (signal !== null) { done(new Error(`process exited by signal ${signal}`)) } else if (code !== 0) { done(new Error(`process exited with exit code ${code}`))
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); }); }
/** * Load an initialize all actions for this form. * * @param req * @param res * @param next */ initialize(method, req, res, next) { this.search(null, method, req, res, (err, actions) => { if (err) { return next(err); } // Iterate through each action. async.forEachOf(actions, (action, index, done) => { if (actions[index].initialize) { actions[index].initialize(method, req, res, done); } else { done(); } }, next); }); }
async.parallel({ document: function(done) { RabbitManager.CalculateDocument(self.Context, function(err, Result) { return done(err, Result); }) }, afcells: function(done) { RabbitManager.CalculateDocument(_.merge(self.Context, { IsAFOnly: true }), function(err, Result) { }) } }, function(err, ComplexResult) { return done(err, ComplexResult.document); })
function run(actions, done) { if (!actions.length) { actions = [actions] } async.each(actions, (action, done) => { async.waterfall([ async.constant(action), ...flow ], (error, result) => { done(error) }) }, done) }
fetchAllPrices (cb) { var self = this /* Every parser works in Parallel, and products prices are fetched sequentially. */ async.each(self.parsers, function (pInstance, done) { // fetch prices of every product in the current parser instance pInstance.fetchPrices(function (url, nProducts) { debug('fetched ' + nProducts + ' for ' + url) done() }) }, function (err) { if (err) return self.emit('error', err) cb && cb() }) }
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.each( Object.keys(references), function(modelRef, done) { var refs = references[modelRef]; var modelClass = self.getClassFromRef(modelRef); if (typeof modelClass === 'undefined') return done(); if (typeof objects[modelRef] === 'undefined') objects[modelRef] = {}; self.loadFromStorageOrCustom(modelRef, modelClass, refs, function(err, objectsIds) { for (var k in objectsIds) { objects[modelRef][k] = objectsIds[k]; } done(err); }); }, function(err) { callback(err, objects); } );
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); }); }
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); }); }