How to use the async-foreach.forEach function in async-foreach

To help you get started, we’ve selected a few async-foreach 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 zurfyx / chat / backend / __tests__ / helper.js View on Github external
beforeEach((done) => {
  // Empty models, so that we start from 0 in each test.
  const connection = mongoose.connection;
  forEach(Object.keys(connection.models), function(collection) {
    const done = this.async();
    connection.models[collection].remove({}).then(() => done());
  }, () => done());
});
github devopsgroup-io / siteshooter / lib / pdf-shooter.js View on Github external
self.website.getContentCollection().then(function(data) {

        utils.log.log('');
        utils.log.log(chalk.yellow.bold(' ⤷ Generating PDF' + (self.options.viewports.length > 1 ?'s' : '')));
        utils.log.log('');

        if(data){
            self.contentCollection = data;
        }

        // create individual pdfs based on viewport
        return asynEach(pdfs, function(item) {

            var done = this.async();

            // make sure we have some screenshots
            if ( item.files.length > 0 ) {
                createPDF(self, item.files, item.dimensions, domainName, outputPath, item.viewport, function() {
                    done();
                });
            } else {

                utils.log.log(chalk.red.bold('   ✗ '), chalk.red('Screenshots for viewport '), chalk.red.bold(item.viewport), chalk.red(' do not exist.'));

                done();
            }

        }, function(success, array) {
github drtechie / moto-g5p-toolkit / main-process / common / adb.js View on Github external
this.getPhones().then(devices => {
        if (devices.length > 0) {
          forEach(devices, (device) => {
            this.checkMotoName(device.id, device.type).then(foundName => {
              if (foundName) {
                resolve(foundName)
              }
            }).catch(() => {
              // do nothing
            })
          })
        } else {
          reject(false)
        }
      })
    })
github drtechie / moto-g5p-toolkit / main-process / common / fastboot.js View on Github external
this.getPhones().then(devices => {
        if (devices.length > 0) {
          forEach(devices, (device) => {
            if (_.includes(device.id, 'permissions')) {
              reject(global.strings.fastbootNoPermissions)
            } else {
              this.checkMotoName(device.id).then(foundName => {
                if (foundName) {
                  resolve(foundName)
                }
              }).catch(() => {
                // do nothing
              })
            }
          })
        } else {
          reject(false)
        }
      }).catch(() => {
github alexbirkett / location.io / test / tracker-simulator.js View on Github external
TrackerSimulator.prototype.sendMessage = function(messages, pauseBetweenMessages, pauseBetweenSlices, sliceLength, callback) {
	var self = this;
	
    if (!isArray(messages)) {
        messages = [messages];
    }
	
	forEach(messages, function(message, index, arr) {
		var done = this.async();

		sendMessage(message, self.client, pauseBetweenSlices, sliceLength, function() {
			setTimeout(function() {
				done();
			}, pauseBetweenMessages);
		});


	}, function() {
		callback();
	});
};
github Urigo / awesome-meteor / build.js View on Github external
forEach(Object.keys(bookmarks), function(section) {
      var links = bookmarks[section];
      var linksDone = this.async();
      forEach(links, function(link) {
        var linkDone = this.async();
        async.series([
          setBookmarkDate.bind(null, link),
          setBookmarkDomain.bind(null, link),
          setBookmarkFavicon.bind(null, link, favicons)
        ], linkDone);
      }, linksDone);
    }, function() {
      done();
github garygreen / dominar / src / dominar.js View on Github external
validateAll: function(passes, fails) {
		passes = passes || Utils.noop;
		fails = fails || Utils.noop;

		var dominar = this;
		var fields = Object.keys(this.options);
		var passedCount = 0;
		forEach(fields, function(item) {
			var done = this.async();
			var field = dominar.getField(item);
			field.validate(function() {
				passedCount++;
				done();
			}, done);
		}, function(success) {
			if (passedCount === fields.length) passes();
			else fails();
		});
	},
github garygreen / dominar / dist / dominar-standalone.js View on Github external
validateAll: function(passes, fails) {
		passes = passes || Utils.noop;
		fails = fails || Utils.noop;

		var dominar = this;
		var fields = Object.keys(this.options);
		var passedCount = 0;
		forEach(fields, function(item) {
			var done = this.async();
			var field = dominar.getField(item);
			field.validate(function() {
				passedCount++;
				done();
			}, done);
		}, function(success) {
			if (passedCount === fields.length) passes();
			else fails();
		});
	},
github garygreen / dominar / dist / dominar.js View on Github external
validateAll: function(passes, fails) {
		passes = passes || Utils.noop;
		fails = fails || Utils.noop;

		var dominar = this;
		var fields = Object.keys(this.options);
		var passedCount = 0;
		forEach(fields, function(item) {
			var done = this.async();
			var field = dominar.getField(item);
			field.validate(function() {
				passedCount++;
				done();
			}, done);
		}, function(success) {
			if (passedCount === fields.length) passes();
			else fails();
		});
	},
github Urigo / awesome-meteor / build.js View on Github external
return function(files, metalsmith, done) {
    var bookmarks = metalsmith.metadata().bookmarks;
    var favicons = getFavicons();
    forEach(Object.keys(bookmarks), function(section) {
      var links = bookmarks[section];
      var linksDone = this.async();
      forEach(links, function(link) {
        var linkDone = this.async();
        async.series([
          setBookmarkDate.bind(null, link),
          setBookmarkDomain.bind(null, link),
          setBookmarkFavicon.bind(null, link, favicons)
        ], linkDone);
      }, linksDone);
    }, function() {
      done();
    });
  };
}

async-foreach

An optionally-asynchronous forEach with an interesting interface.

MIT
Latest version published 12 years ago

Package Health Score

61 / 100
Full package analysis

Popular async-foreach functions