Skip to content

Commit

Permalink
Meta tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Jan 1, 2020
1 parent 056c0f3 commit f005eee
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 22 deletions.
26 changes: 13 additions & 13 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
export interface Limit {
/**
* @param fn - Promise-returning/async function.
* @param arguments - Any arguments to pass through to `fn`. Support for passing arguments on to the `fn` is provided in order to be able to avoid creating unnecessary closures. You probably don't need this optimization unless you're pushing a lot of functions.
* @returns The promise returned by calling `fn(...arguments)`.
*/
@param fn - Promise-returning/async function.
@param arguments - Any arguments to pass through to `fn`. Support for passing arguments on to the `fn` is provided in order to be able to avoid creating unnecessary closures. You probably don't need this optimization unless you're pushing a lot of functions.
@returns The promise returned by calling `fn(...arguments)`.
*/
<Arguments extends unknown[], ReturnType>(
fn: (...arguments: Arguments) => PromiseLike<ReturnType> | ReturnType,
...arguments: Arguments
): Promise<ReturnType>;

/**
* The number of promises that are currently running.
*/
The number of promises that are currently running.
*/
readonly activeCount: number;

/**
* The number of promises that are waiting to run (i.e. their internal `fn` was not called yet).
*/
The number of promises that are waiting to run (i.e. their internal `fn` was not called yet).
*/
readonly pendingCount: number;
}

/**
* Run multiple promise-returning & async functions with limited concurrency.
*
* @param concurrency - Concurrency limit. Minimum: `1`.
* @returns A `limit` function.
*/
Run multiple promise-returning & async functions with limited concurrency.
@param concurrency - Concurrency limit. Minimum: `1`.
@returns A `limit` function.
*/
export default function pLimit(concurrency: number): Limit;
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"description": "Run multiple promise-returning & async functions with limited concurrency",
"license": "MIT",
"repository": "sindresorhus/p-limit",
"funding": "https://github.com/sponsors/sindresorhus",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
Expand Down
12 changes: 3 additions & 9 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@

> Run multiple promise-returning & async functions with limited concurrency

## Install

```
$ npm install p-limit
```


## Usage

```js
Expand All @@ -30,7 +28,6 @@ const input = [
})();
```


## API

### pLimit(concurrency)
Expand All @@ -39,8 +36,8 @@ Returns a `limit` function.

#### concurrency

Type: `number`<br>
Minimum: `1`<br>
Type: `number`\
Minimum: `1`\
Default: `Infinity`

Concurrency limit.
Expand Down Expand Up @@ -69,13 +66,11 @@ The number of promises that are currently running.

The number of promises that are waiting to run (i.e. their internal `fn` was not called yet).


## FAQ

### How is this different from the [`p-queue`](https://github.com/sindresorhus/p-queue) package?

This package is only about limiting the number of concurrent executions, while `p-queue` is a fully featured queue implementation with lots of different options, introspection, and ability to pause and clear the queue.

This package is only about limiting the number of concurrent executions, while `p-queue` is a fully featured queue implementation with lots of different options, introspection, and ability to pause the queue.

## Related

Expand All @@ -85,7 +80,6 @@ This package is only about limiting the number of concurrent executions, while `
- [p-all](https://github.com/sindresorhus/p-all) - Run promise-returning & async functions concurrently with optional limited concurrency
- [More…](https://github.com/sindresorhus/promise-fun)


---

<div align="center">
Expand Down

0 comments on commit f005eee

Please sign in to comment.