How to use the async.series function in async

To help you get started, we’ve selected a few async examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github assemble / assemble / lib / core / render.js View on Github external
function (pageKey, nextPage) {

          // add the current page to the params
          // so middleware and make modifications if needed.
          params.page = assemble.pages[pageKey];
          utils.context(assemble, params);

          // run steps in series so we can notify middleware
          // before and after the page steps are done.
          async.series([

            // notify middleware before rendering the contents
            notify(events.pageBeforeRender),

            // render the page
            function (nextRenderStep) {
              assemble.log.debug('\t[render]:', 'rendering pages');

              assemble.engine.render(params.page.content, params.context, assemble.config, function (err, content) {
                assemble.log.debug('\t[render]:', 'rendering done.');
                if (err) {
                  assemble.log.error(err);
                  return nextRenderStep(err);
                }
                assemble.pages[pageKey].content = content;
                nextRenderStep();
github StellarFw / stellar / src / satellites / actionProcessor.js View on Github external
return
    }

    let processors = []
    let processorsNames = self.api.actions.globalMiddleware.slice(0)

    // get action processor names
    if (self.actionTemplate.middleware) { self.actionTemplate.middleware.forEach(m => { processorsNames.push(m) }) }

    processorsNames.forEach(name => {
      if (typeof self.api.actions.middleware[ name ].preProcessor === 'function') {
        processors.push(next => { self.api.actions.middleware[ name ].preProcessor(self, next) })
      }
    })

    async.series(processors, callback)
  }
github oracle / node-oracledb / test / changePassword.js View on Github external
it('161.5 for DBA, the original password is ignored', function(done) {

    var dbaConn, conn;
    var tpass = 'secret';

    async.series([
      function(cb) {
        oracledb.getConnection(
          DBA_config,
          function(err, connection) {
            should.not.exist(err);
            dbaConn = connection;
            cb();
          }
        );
      },
      function(cb) {
        dbaConn.changePassword(myUser, 'foobar', tpass, function(err) {
          should.not.exist(err);
          cb();
        });
      },
github taskrabbit / elasticsearch-dump / test / parentchild.js View on Github external
})

    people.forEach(person => {
      jobs.push(done => {
        const url = baseUrl + '/source_index/person/' + person + '_' + city + '?parent=' + city
        const payload = { name: person, city: city }
        request.put(url, { body: JSON.stringify(payload) }, done)
      })
    })
  })

  jobs.push(done => {
    setTimeout(done, 6000)
  })

  async.series(jobs, callback)
}
github weareswat / jira-github-issue-sync / lib / syncer.js View on Github external
exports.process = function process(config) {
    context.config = config;
    context.api = configApis(config);
    async.series([
      buildMilestone,
      getSprintIssues,
      getClosedSprintIssues,
      createJiraTasksOnGithub,
      closeJiraTasks
    ], errorLog);
  };
github apostrophecms / apostrophe-workflow / lib / routes.js View on Github external
function forceExport(callback) {
        return async.series([
          getOriginal,
          force
        ], callback);
        function getOriginal(callback) {
          return self.apos.docs.find(req, { workflowGuid: workflowGuid }).trash(null).published(null).toObject(function(err, _original) {
            if (err) {
              return callback(err);
            }
            if (!_original) {
              return callback('notfound');
            }
            original = _original;
            return callback(null);
          });
        }
        function force(callback) {
github thegameofcode / cipherlayer / src / managers / dao.js View on Github external
function (done) {
				usersCollection = connectedDb.collection('users');
				async.series([
					function (next) {
						usersCollection.ensureIndex('_id', next);
					},
					function (next) {
						usersCollection.ensureIndex('username', next);
					},
					function (next) {
						usersCollection.ensureIndex('password', next);
					}
				], done);
			},
			function (done) {
github Houfeng / cize / lib / series.js View on Github external
runable: function (self) {
      async.series(ChildJobs.map(function (ChildJob) {
        return function (next) {
          self.invoke(ChildJob, next);
        };
      }), function (err, result) {
        if (self.context.hasFailed()) {
          err = new Error(`QueueFailed: ${err && err.message}`);
        }
        self.done(err, result);
      });
    }
  }
github z-classic / z-nomp / libs / profitSwitch.js View on Github external
depthTasks.push(function(callback){
                            _this.getMarketDepthFromPoloniex('BTC', symbol, marketData['BTC'].bid, callback) 
                        });
                    }
                    if (marketData.hasOwnProperty('LTC') && marketData['LTC'].bid > 0){
                        depthTasks.push(function(callback){
                            _this.getMarketDepthFromPoloniex('LTC', symbol, marketData['LTC'].bid, callback) 
                        });
                    }
                });

                if (!depthTasks.length){
                    taskCallback();
                    return;
                }
                async.series(depthTasks, function(err){
                    if (err){
                        taskCallback(err);
                        return;
                    }
                    taskCallback();
                });
            }
        ], function(err){
github bakkerthehacker / bramqp / lib / connectionHandle.js View on Github external
closeAMQPCommunication(callback) {
		async.series([(seriesCallback) => {
			this.channel.close(1, 200, 'Closing channel');
			this.once('1:channel.close-ok', () => {
				seriesCallback();
			});
		}, (seriesCallback) => {
			this.connection.close(200, 'Closing channel');
			this.once('connection.close-ok', () => {
				seriesCallback();
			});
		}, (seriesCallback) => {
			clearInterval(this.heartbeatIntervalId);
			seriesCallback();
		}], callback);
	}
	setFrameMax(frameMax) {