Skip to content

Commit

Permalink
Update readme.md
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus authored Dec 19, 2024
1 parent 1596c9b commit 0fb0b78
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,19 @@ The returned function manages its own concurrent executions, allowing you to cal

Ideal for scenarios where you need to control the number of simultaneous executions of a single function, rather than managing concurrency across multiple functions.

```js
import {limitFunction} from 'p-limit';

const limitedFunction = limitFunction(async () => {
return doSomething();
}, {concurrency: 1});

const input = Array.from({length: 10}, limitedFunction);

// Only one promise is run at once.
await Promise.all(input);
```

#### fn

Type: `Function`
Expand All @@ -100,18 +113,7 @@ Type: `object`
Type: `number`\
Minimum: `1`

```js
import {limitFunction} from 'p-limit';

const limitFunction_ = limitFunction(async () => {
return doSomething();
}, {concurrency: 1});

const input = Array.from({length: 10}, limitFunction_);

// Only one promise is run at once
await Promise.all(input);
```
Concurrency limit.

## FAQ

Expand Down

0 comments on commit 0fb0b78

Please sign in to comment.