Socket
Book a DemoSign in
Socket

p-limit

Package Overview
Dependencies
Maintainers
1
Versions
24
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
7.0.0
to
7.1.0
+4
-2
index.d.ts

@@ -29,4 +29,6 @@ export type LimitFunction = {

The mapper function receives the item value and its index.
@param array - An array containing an argument for the given function.
@param function_ - Promise-returning/async function.
@param mapperFunction - Promise-returning/async function.
@returns A Promise that returns an array of results.

@@ -36,3 +38,3 @@ */

array: Input[],
function_: (input: Input) => PromiseLike<ReturnType> | ReturnType
mapperFunction: (input: Input, index: number) => PromiseLike<ReturnType> | ReturnType
) => Promise<ReturnType[]>;

@@ -39,0 +41,0 @@

@@ -86,3 +86,3 @@ import Queue from 'yocto-queue';

async value(array, function_) {
const promises = array.map(value => this(function_, value));
const promises = array.map((value, index) => this(function_, value, index));
return Promise.all(promises);

@@ -89,0 +89,0 @@ },

{
"name": "p-limit",
"version": "7.0.0",
"version": "7.1.0",
"description": "Run multiple promise-returning & async functions with limited concurrency",

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

@@ -60,8 +60,10 @@ # p-limit

### limit.map(array, fn)
### limit.map(array, mapperFunction)
Process an array of inputs with limited concurrency.
Returns a promise equivalent to `Promise.all(array.map(item => limit(fn, item)))`.
The mapper function receives the item value and its index.
Returns a promise equivalent to `Promise.all(array.map((item, index) => limit(mapperFunction, item, index)))`.
This is a convenience function for processing inputs that arrive in batches. For more complex use cases, see [p-map](https://github.com/sindresorhus/p-map).

@@ -68,0 +70,0 @@