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

@types/async

Package Overview
Dependencies
Maintainers
1
Versions
69
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@types/async

TypeScript definitions for async

  • 3.2.24
  • ts4.5
  • ts4.6
  • ts4.7
  • ts4.8
  • ts4.9
  • ts5.0
  • ts5.1
  • ts5.2
  • ts5.3
  • ts5.4
  • ts5.5
  • ts5.6
  • ts5.7
  • ts5.8
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is @types/async?

@types/async provides TypeScript type definitions for the async library, which is a utility module that provides straight-forward, powerful functions for working with asynchronous JavaScript. It allows you to manage asynchronous control flow using various patterns such as series, parallel, waterfall, and more.

What are @types/async's main functionalities?

Series

Executes a list 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 callback for the series is immediately called with the value of the error.

const async = require('async');
async.series([
  function(callback) {
    setTimeout(function() {
      console.log('Task 1');
      callback(null, 'one');
    }, 200);
  },
  function(callback) {
    setTimeout(function() {
      console.log('Task 2');
      callback(null, 'two');
    }, 100);
  }
],
function(err, results) {
  console.log(results);
});

Parallel

Executes a list of functions in parallel, without waiting until the previous function has completed. If any functions in the series pass an error to its callback, the main callback is immediately called with the value of the error.

const async = require('async');
async.parallel([
  function(callback) {
    setTimeout(function() {
      console.log('Task 1');
      callback(null, 'one');
    }, 200);
  },
  function(callback) {
    setTimeout(function() {
      console.log('Task 2');
      callback(null, 'two');
    }, 100);
  }
],
function(err, results) {
  console.log(results);
});

Waterfall

Runs an array of functions in series, each passing their results to the next in the array. However, if any of the functions pass an error to the callback, the next function is not executed and the main callback is immediately called with the error.

const async = require('async');
async.waterfall([
  function(callback) {
    callback(null, 'one', 'two');
  },
  function(arg1, arg2, callback) {
    console.log(arg1, arg2);
    callback(null, 'three');
  },
  function(arg1, callback) {
    console.log(arg1);
    callback(null, 'done');
  }
],
function (err, result) {
  console.log(result);
});

Other packages similar to @types/async

FAQs

Package last updated on 22 Nov 2023

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