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

async

Package Overview
Dependencies
Maintainers
2
Versions
93
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

async

Higher-order functions and common patterns for asynchronous code

  • 0.9.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
57M
decreased by-2.21%
Maintainers
2
Weekly downloads
 
Created

What is async?

The async npm package provides utility functions for working with asynchronous JavaScript. It offers a variety of powerful control flow functions and utilities to work with asynchronous operations, helping to manage callbacks, reduce boilerplate code, and increase readability.

What are async's main functionalities?

Control Flow

Execute an array of functions in series, each one running once the previous function has completed. If any functions in the series pass an error to its callback, no more functions are run, and the main callback is immediately called with the value of the error.

async.series([
  function(callback) { 
    // do some stuff ...
    callback(null, 'one'); 
  },
  function(callback) { 
    // do some more stuff ...
    callback(null, 'two'); 
  }
],
function(err, results) {
  // results is now equal to ['one', 'two']
});

Collections

Apply a function to each item in a collection and collect the results. For example, you can use `async.map` to get the file stats for an array of file names.

async.map(['file1','file2','file3'], fs.stat, function(err, results) {
  // results is now an array of stats for each file
});

Utilities

Repeatedly call a function a set number of times and collect the results. It's useful for seeding databases, among other things.

async.times(5, function(n, next) {
  createUser(n, function(err, user) {
    next(err, user);
  });
}, function(err, users) {
  // we should now have 5 users
});

Other packages similar to async

Keywords

FAQs

Package last updated on 19 May 2015

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