Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

async-it

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

async-it

Generic asynchronous iterators for node.js.

  • 0.4.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
27
increased by35%
Maintainers
1
Weekly downloads
 
Created
Source

async-it

async-it is a series of generic asynchronous parallel and serial iterators for node.js.

These iterators are based on the ES5 additions to Array (forEach, map, filter, some, any, reduce and reduceRight). reduce and reduceRight are available in serial mode only.

Indexes are only passed to the callback in the aptly-named forEachWithIndex for fear of crowding the callback with little used arguments.

Like their sync counterparts, these iterators work on any object which has a numeric length property.

Usage

See examples/example.js:

var path = require('path'),
    fs = require('fs'),
    asyncItParallel = require('async-it').parallel;

var files = ['foo.txt', 'bar.txt', 'does-not-exist.txt', 'baz.txt'];
files = files.map(function(file) {
  return path.join(__dirname, 'files', file);
});

// select existing files
asyncItParallel.filter(files, function(file, cont) {
  fs.exists(file, function(exists) {
    cont(null, exists);
  });
}, function(err, existingFiles) {
  // collect their content
  asyncItParallel.map(existingFiles, function(file, cont) {
    fs.readFile(file, 'utf8', cont);
  }, function(err, content) {
    // output the ordered content to the console
    console.log(content.join('\n'));
  });
});

// Hi, I'm foo!
// Hello World, this is bar.
// I'm baz.

License

Licensed under the MIT license, Copyright 2010 Tobie Langel.

FAQs

Package last updated on 08 Sep 2014

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc