Socket
Socket
Sign inDemoInstall

tiny-each-async

Package Overview
Dependencies
0
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    tiny-each-async

Asynchronous iterator function for parallel processing.


Version published
Maintainers
1
Install size
4.69 kB
Created

Readme

Source

tiny-async-each

Asynchronous iterator function, similar to (and inspired by) async.each.

build status

Usage

each(array, iterator, [callback])

Arguments:

  • array - An array of items to iterate through.
  • iterator(item, [index], callback) - A function to be applied to each item in the array. When it has finished processing the item then the callback function should be called (in case of a failure with the error argument, otherwise none).
  • callback(err) - An optional callback function that gets called when either all iterator functions have finished or one of them has returned an error.

Example

var eachAsync = require('tiny-each-async');
var timeouts = [300, 100, 2000];

eachAsync(['file1', 'file2', 'file3'], function(item, index, next) {
  setTimeout(function() {
    console.log(item, index, timeouts[index]);
    next();
  }, timeouts[index]);
}, function(err) {
  return err ? console.error(err.stack) : console.log('all done');
});

FAQ

  • Why the name?

Other possible names were already taken, and the actual source code is tiny.

  • Why create another async library?

Because doing your own thing is fun.

License

MIT

Keywords

FAQs

Last updated on 26 Oct 2015

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc