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

p-limit

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

p-limit - npm Package Compare versions

Comparing version 6.0.0 to 6.1.0

5

index.d.ts

@@ -13,2 +13,7 @@ export type LimitFunction = {

/**
Get or set the concurrency limit.
*/
concurrency: number;
/**
Discard pending promises that are waiting to run.

@@ -15,0 +20,0 @@

27

index.js
import Queue from 'yocto-queue';
export default function pLimit(concurrency) {
if (!((Number.isInteger(concurrency) || concurrency === Number.POSITIVE_INFINITY) && concurrency > 0)) {
throw new TypeError('Expected `concurrency` to be a number from 1 and up');
}
validateConcurrency(concurrency);

@@ -12,3 +10,3 @@ const queue = new Queue();

const resumeNext = () => {
if (queue.size > 0) {
if (activeCount < concurrency && queue.size > 0) {
queue.dequeue()();

@@ -76,2 +74,17 @@ // Since `pendingCount` has been decreased by one, increase `activeCount` by one.

},
concurrency: {
get: () => concurrency,
set(newConcurrency) {
validateConcurrency(newConcurrency);
concurrency = newConcurrency;
queueMicrotask(() => {
// eslint-disable-next-line no-unmodified-loop-condition
while (activeCount < concurrency && queue.size > 0) {
resumeNext();
}
});
},
},
});

@@ -81,1 +94,7 @@

}
function validateConcurrency(concurrency) {
if (!((Number.isInteger(concurrency) || concurrency === Number.POSITIVE_INFINITY) && concurrency > 0)) {
throw new TypeError('Expected `concurrency` to be a number from 1 and up');
}
}

2

package.json
{
"name": "p-limit",
"version": "6.0.0",
"version": "6.1.0",
"description": "Run multiple promise-returning & async functions with limited concurrency",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -77,2 +77,6 @@ # p-limit

### limit.concurrency
Get or set the concurrency limit.
## FAQ

@@ -79,0 +83,0 @@

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