+4
-2
@@ -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 @@ |
+1
-1
@@ -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 @@ }, |
+1
-1
| { | ||
| "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", |
+4
-2
@@ -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 @@ |
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
11716
1.75%162
0.62%141
1.44%