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.1.1
to
7.2.0
+3
-3
index.d.ts

@@ -27,7 +27,7 @@ export type LimitFunction = {

/**
Process an array of inputs with limited concurrency.
Process an iterable of inputs with limited concurrency.
The mapper function receives the item value and its index.
@param array - An array containing an argument for the given function.
@param iterable - An iterable containing an argument for the given function.
@param mapperFunction - Promise-returning/async function.

@@ -37,3 +37,3 @@ @returns A Promise that returns an array of results.

map: <Input, ReturnType> (
array: readonly Input[],
iterable: Iterable<Input>,
mapperFunction: (input: Input, index: number) => PromiseLike<ReturnType> | ReturnType

@@ -40,0 +40,0 @@ ) => Promise<ReturnType[]>;

@@ -85,4 +85,4 @@ import Queue from 'yocto-queue';

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

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

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

@@ -52,3 +52,2 @@ "license": "MIT",

"ava": "^6.4.1",
"delay": "^6.0.0",
"in-range": "^3.0.0",

@@ -55,0 +54,0 @@ "random-int": "^3.0.0",

@@ -60,9 +60,9 @@ # p-limit

### limit.map(array, mapperFunction)
### limit.map(iterable, mapperFunction)
Process an array of inputs with limited concurrency.
Process an iterable of inputs with limited concurrency.
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)))`.
Returns a promise equivalent to `Promise.all(Array.from(iterable, (item, index) => limit(mapperFunction, item, index)))`.

@@ -69,0 +69,0 @@ 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).