Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Generated on Apr 22, 2024 via pnpm

p-limit 3.1.0

Run multiple promise-returning & async functions with limited concurrency
Package summary
Share
0
issues
1
license
2
MIT
Package created
21 Oct 2016
Version published
25 Nov 2020
Maintainers
1
Total deps
2
Direct deps
1
License
MIT

Issues

0
This package has no issues

Licenses

MIT License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
sublicense
private-use
Cannot
hold-liable
Must
include-copyright
include-license
2 Packages, Including:
p-limit@3.1.0
yocto-queue@0.1.0
Disclaimer

This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.

Sandworm is not a law firm and does not provide legal services. Distributing, displaying, or linking to this deed or the license that it summarizes does not create a lawyer-client or any other relationship.

Direct Dependencies

1
All Dependencies CSV
β“˜ This is a list of p-limit 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities
yocto-queue0.1.02.7 kBMIT
prod

Visualizations

Frequently Asked Questions

What does p-limit do?

p-limit is a powerful utility package in npm that principally helps in executing multiple promise-returning and asynchronous functions with limited concurrency. Effectively, it allows you to limit the number of promises or asynchronous functions running concurrently, aiding in performance control and process management.

How do you use p-limit?

To use p-limit, first, install the npm package using npm install p-limit. Next, you import the package into your project using import pLimit from 'p-limit';. Once imported, you can initiate p-limit with the desired concurrency limit, for example, const limit = pLimit(1);. Then, you wrap the asynchronous functions or promises you want to limit within the limit function. Here's a basic usage example:

import pLimit from 'p-limit';

// Initialize p-limit with a concurrency limit of 1
const limit = pLimit(1);

const input = [
    // Wrap the async functions within the limit function
    limit(() => fetchSomething('foo')),
    limit(() => fetchSomething('bar')),
    limit(() => doSomething())
];

// Only one promise is run at once
const result = await Promise.all(input);
console.log(result);

In this example, even if the fetchSomething and doSomething functions are asynchronous, they will be executed one by one because pLimit is configured with a concurrency limit of 1.

Where are the p-limit docs?

The documentation for p-limit, including its usage details and API reference, is contained within its GitHub readme at https://github.com/sindresorhus/p-limit. The documentation provides detailed descriptions of its API functionalities such as pLimit(concurrency), limit(fn, ...args), limit.activeCount, limit.pendingCount, and limit.clearQueue(). In addition to that, it explains what p-limit is, how it varies from the p-queue package, and how to install and use the package efficaciously.