🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

array-parallel

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

array-parallel

Call an array of asynchronous functions in parallel

0.1.3
latest
Source
npm
Version published
Weekly downloads
450K
-1.25%
Maintainers
1
Weekly downloads
 
Created

What is array-parallel?

The array-parallel npm package allows you to run an array of asynchronous functions in parallel and collect their results. It is useful for scenarios where you need to perform multiple asynchronous operations concurrently and wait for all of them to complete.

What are array-parallel's main functionalities?

Running asynchronous functions in parallel

This feature allows you to run multiple asynchronous tasks in parallel. The provided code sample demonstrates how to define an array of asynchronous functions and execute them concurrently using the array-parallel package. The results of the tasks are collected and returned in the same order as the tasks array.

const parallel = require('array-parallel');

const tasks = [
  function(callback) {
    setTimeout(() => {
      callback(null, 'Task 1 complete');
    }, 1000);
  },
  function(callback) {
    setTimeout(() => {
      callback(null, 'Task 2 complete');
    }, 500);
  },
  function(callback) {
    setTimeout(() => {
      callback(null, 'Task 3 complete');
    }, 1500);
  }
];

parallel(tasks, (err, results) => {
  if (err) {
    console.error(err);
  } else {
    console.log(results); // ['Task 1 complete', 'Task 2 complete', 'Task 3 complete']
  }
});

Other packages similar to array-parallel

FAQs

Package last updated on 14 Dec 2013

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