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

p-map-series

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

p-map-series

Map over promises serially

  • 2.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2M
increased by2.16%
Maintainers
1
Weekly downloads
 
Created

What is p-map-series?

The p-map-series npm package allows you to map over promises serially. It processes each promise one after another, ensuring that only one promise is running at a time. This is useful for tasks that need to be performed in sequence rather than in parallel.

What are p-map-series's main functionalities?

Serial Processing

This feature allows you to process an array of promise-returning functions in series. Each task is executed one after another, ensuring that only one task is running at any given time.

const pMapSeries = require('p-map-series');

const tasks = [
  () => Promise.resolve('Task 1'),
  () => Promise.resolve('Task 2'),
  () => Promise.resolve('Task 3')
];

pMapSeries(tasks).then(results => {
  console.log(results); // ['Task 1', 'Task 2', 'Task 3']
});

Error Handling

This feature demonstrates how p-map-series handles errors. If any task in the series fails, the entire process stops, and the error is caught in the catch block.

const pMapSeries = require('p-map-series');

const tasks = [
  () => Promise.resolve('Task 1'),
  () => Promise.reject(new Error('Task 2 failed')),
  () => Promise.resolve('Task 3')
];

pMapSeries(tasks).then(results => {
  console.log(results);
}).catch(error => {
  console.error(error); // Error: Task 2 failed
});

Other packages similar to p-map-series

Keywords

FAQs

Package last updated on 15 Mar 2019

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