How to use the async.apply 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 CoderDojo / cp-dojos-service / dojos.js View on Github external
function cmd_delete(args, done){
    // TODO - there must be other data to remove if we delete a dojo??
    var user = args.user;
    var query = {userId:user.id, dojoId:args.id};

    async.waterfall([
      async.apply(isUserChampionAndDojoAdmin, query, user),
      deleteDojo,
      deleteUsersDojos,
      deleteDojoLead,
      deleteSalesForce
    ], done);

    function deleteDojo(hasPermission, done) {
      if(hasPermission) {
        var dojo = {
          id: args.id,
          deleted: 1,
          deletedBy: args.user.id,
          deletedAt: new Date()
        };
        seneca.make$(ENTITY_NS).save$(dojo, done);
github hoodiehq / hoodie / test / integration / plugins / api / test-plugin-api.js View on Github external
hoodie.database.add('foo', function (err, db) {
    if (err) {
      return test.done(err)
    }
    var doc1 = {id: 'wibble', title: 'Test Document 1'}
    var doc2 = {id: 'wobble', title: 'Test Document 2'}
    async.parallel([
      async.apply(db.add, 'mytype', doc1),
      async.apply(db.add, 'mytype', doc2)
    ], function (err) {
      if (err) {
        return test.done(err)
      }
      db.findAll(function (err, docs) {
        if (err) {
          return test.done(err)
        }
        test.equal(docs.length, 2)
        test.equal(docs[0].id, 'wibble')
        test.equal(docs[0].type, 'mytype')
        test.equal(docs[0].title, 'Test Document 1')
        test.equal(docs[1].id, 'wobble')
        test.equal(docs[1].type, 'mytype')
        test.equal(docs[1].title, 'Test Document 2')
github hoodiehq / hoodie / test / integration / plugins / api / test-plugin-api.js View on Github external
exports['account.add / findAll / get / remove / update'] = function (test) {
  var hoodie = new PluginAPI(DEFAULT_OPTIONS)
  var userdoc = {
    id: 'testuser',
    password: 'testing'
  }
  async.series([
    async.apply(hoodie.account.findAll, 'user'),
    async.apply(hoodie.account.add, 'user', userdoc),
    hoodie.account.findAll,
    async.apply(hoodie.account.find, 'user', 'testuser'),
    async.apply(hoodie.account.update, 'user', 'testuser', {wibble: 'wobble'}),
    async.apply(hoodie.account.find, 'user', 'testuser'),
    async.apply(hoodie.account.remove, 'user', 'testuser'),
    hoodie.account.findAll
  ], function (err, results) {
    if (err) {
      return test.done(err)
    }
    var docs1 = results[0]
    var docs2 = results[2]
    var userdoc1 = results[3]
    var userdoc2 = results[5]
    var docs3 = results[7]
github NodeBB / NodeBB / src / middleware / header.js View on Github external
languageDirection: function (next) {
						translator.translate('[[language:dir]]', res.locals.config.userLang, function (translated) {
							next(null, translated);
						});
					},
					browserTitle: function (next) {
						translator.translate(controllers.helpers.buildTitle(translator.unescape(data.title)), function (translated) {
							next(null, translated);
						});
					},
					navigation: async.apply(navigation.get, req.uid),
					banned: async.apply(user.bans.isBanned, req.uid),
					banReason: async.apply(user.bans.getReason, req.uid),

					unreadData: async.apply(topics.getUnreadData, { uid: req.uid }),
					unreadChatCount: async.apply(messaging.getUnreadCount, req.uid),
					unreadNotificationCount: async.apply(user.notifications.getUnreadCount, req.uid),
				}, next);
			},
			function (results, next) {
github eclipse-iofog / Controller / src / server / controllers / api / oroController.js View on Github external
}
        };


    if (AppUtils.getProperty(params, props.publishingFogInstance + '.uuid')
        === AppUtils.getProperty(params, props.destinationFogInstanceUUID + '.uuid')) {
        watefallMethods = [
            async.apply(RoutingService.createRoute, routingProps, params),
            async.apply(ElementInstanceService.getElementInstanceRouteDetails, destElementProps),
            async.apply(ElementInstanceService.updateElemInstance, updateRebuildPubProps),
            async.apply(ElementInstanceService.updateElemInstance, updateRebuildDestProps),
            async.apply(ChangeTrackingService.updateChangeTracking, pubChangeTrackingProps)
        ];
    } else {
        watefallMethods = [
            async.apply(ComsatService.openPortOnRadomComsat, params),
            createSatellitePort,

            async.apply(ElementService.getNetworkElement, pubNetworkElementProps),
            async.apply(createPubNetworkElementInstance, pubNetworkElementInstanceProps),

            async.apply(ElementService.getNetworkElement, destNetworkElementProps),
            async.apply(createDestNetworkElementInstance, destNetworkElementInstanceProps),

            async.apply(NetworkPairingService.createNetworkPairing, networkPairingProps),

            async.apply(RoutingService.createRoute, pubRoutingProps),
            async.apply(RoutingService.createRoute, destRoutingProps),

            async.apply(ElementInstanceService.updateElemInstance, updateRebuildPubProps),
            async.apply(ElementInstanceService.updateElemInstance, updateRebuildDestProps),
github formio / formio / src / middleware / bootstrapNewRoleAccess.js View on Github external
fns.forEach(function(f) {
      bound.push(async.apply(f, roleId));
    });
github bermi / sauce-connect-launcher / lib / sauce-connect-launcher.js View on Github external
function fetchAndCheckArchive(archiveName, archivefile, checksum, callback) {
  return async.waterfall([
    async.apply(fetchArchive, archiveName, archivefile),
    async.apply(verifyChecksum, archivefile, checksum)
  ], callback);
}
github xuanvu / flat / lib / realTime.js View on Github external
RealTime.prototype.loadScore = function (scoreId, callback) {
  var score = { users: {}, events: [] };
  async.waterfall([
    async.apply(schema.models.Score.find.bind(schema.models.Score), scoreId),
    function (scoredb, callback) {
      score.scoredb = scoredb;
      score.git = new Score(scoredb.sid);
      score.git.getScore('master', callback);
    },
    function (scoreContent, callback) {
      score.fdata = new Fermata.Data(JSON.parse(scoreContent));
      this.scores[scoreId] = score;
      callback();
    }.bind(this)
  ], callback);
};
github NodeBB / NodeBB / src / reports.js View on Github external
async.each(hooks, function (hook, next) {
			async.parallel({
				'hourly': async.apply(analytics.getHourlyStatsForSet, 'analytics:' + hook.type + ':' + hook.hook, Date.now(), 24),
				'daily': async.apply(analytics.getDailyStatsForSet, 'analytics:' + hook.type + ':' + hook.hook, Date.now(), 30)
			}, function (err, stats) {
				hook.stats = stats;
				next(err);
			});
		}, function(err) {
			callback(err, hooks);
github eclipse-iofog / Controller / src / server / controllers / api / elementInstanceController.js View on Github external
if(req.query.t){
      params.bodyParams.t = req.query.t;
  }
  params.bodyParams.trackId = req.params.trackId;
  logger.info("Parameters:" + JSON.stringify(params.bodyParams));

  async.waterfall([
    async.apply(UserService.getUser, userProps, params),
    async.apply(ElementInstanceService.getDetailedElementInstances, elementInstanceProps),
    async.apply(ElementInstanceConnectionsService.findBySourceElementInstance, elementInstanceConnectionProps),
    async.apply(ElementInstancePortService.findElementInstancePortsByElementIds, elementInstancePortProps),
    async.apply(NetworkPairingService.findByElementInstancePortId, networkPairingProps),
    async.apply(SatellitePortService.findBySatellitePortIds, satellitePortProps),
    async.apply(SatelliteService.findBySatelliteIds, satelliteProps),
    async.apply(RoutingService.isDebugging, debugProps),
    async.apply(RoutingService.isViewer, viewerProps),
    async.apply(ElementInstanceService.getDataTrackDetails, dataTrackProps),
    getElementInstanceDetails

  ], function(err, result) {
    AppUtils.sendResponse(res, err, 'instance', params.response, result);
  });
};