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

fastparallel

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fastparallel

Zero-overhead asynchronous parallel/each/map function call

  • 2.4.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
217K
decreased by-9.69%
Maintainers
1
Weekly downloads
 
Created

What is fastparallel?

The fastparallel npm package is designed to handle parallel function execution efficiently. It allows you to run multiple asynchronous tasks in parallel and collect their results once all tasks are completed. This can be particularly useful for scenarios where you need to perform multiple I/O-bound operations concurrently.

What are fastparallel's main functionalities?

Parallel Execution

This feature allows you to execute multiple asynchronous tasks in parallel. The provided code sample demonstrates how to run two tasks concurrently and collect their results once both tasks are completed.

const fastparallel = require('fastparallel')();

function task1(arg, cb) {
  setTimeout(() => cb(null, 'result1'), 100);
}

function task2(arg, cb) {
  setTimeout(() => cb(null, 'result2'), 200);
}

fastparallel(null, [task1, task2], 'argument', (err, results) => {
  if (err) throw err;
  console.log(results); // ['result1', 'result2']
});

Error Handling

This feature demonstrates how fastparallel handles errors in parallel tasks. If any task encounters an error, the final callback receives the error, and the results array is not populated.

const fastparallel = require('fastparallel')();

function task1(arg, cb) {
  setTimeout(() => cb(null, 'result1'), 100);
}

function task2(arg, cb) {
  setTimeout(() => cb(new Error('Something went wrong'), null), 200);
}

fastparallel(null, [task1, task2], 'argument', (err, results) => {
  if (err) {
    console.error(err.message); // 'Something went wrong'
  } else {
    console.log(results);
  }
});

Other packages similar to fastparallel

Keywords

FAQs

Package last updated on 19 Oct 2021

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