Skip to content

Commit

Permalink
Readme tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Apr 14, 2020
1 parent 84edbf5 commit 49ac711
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
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": "Promise queue with concurrency control",
"license": "MIT",
"repository": "sindresorhus/p-queue",
"funding": "https://github.com/sponsors/sindresorhus",
"main": "dist/index.js",
"engines": {
"node": ">=8"
Expand Down
13 changes: 2 additions & 11 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@
Useful for rate-limiting async (or sync) operations. For example, when interacting with a REST API or when doing CPU/memory intensive tasks.


## Install

```
$ npm install p-queue
```


## Usage

Here we run only one promise at the time. For example, set `concurrency` to 4 to run four promises at the same time.
Expand All @@ -28,8 +26,8 @@ const queue = new PQueue({concurrency: 1});
})();

(async () => {
await queue.add(() => got('https://ava.li'));
console.log('Done: ava.li');
await queue.add(() => got('https://avajs.dev'));
console.log('Done: avajs.dev');
})();

(async () => {
Expand All @@ -39,7 +37,6 @@ const queue = new PQueue({concurrency: 1});
})();
```


## API

### PQueue(options?)
Expand Down Expand Up @@ -166,7 +163,6 @@ Clear the queue.

Size of the queue.


#### .sizeBy(options)

Size of the queue, filtered by the given options.
Expand Down Expand Up @@ -199,7 +195,6 @@ Number of pending promises.

Whether the queue is currently paused.


## Events

#### active
Expand All @@ -224,7 +219,6 @@ queue.add(() => Promise.resolve());
queue.add(() => delay(500));
```


## Advanced example

A more advanced example to help you understand the flow.
Expand Down Expand Up @@ -295,7 +289,6 @@ $ node example.js
12. All work is done
```


## Custom QueueClass

For implementing more complex scheduling policies, you can provide a QueueClass in the options:
Expand Down Expand Up @@ -326,7 +319,6 @@ class QueueClass {

`p-queue` will call corresponding methods to put and get operations from this queue.


## Related

- [p-limit](https://github.com/sindresorhus/p-limit) - Run multiple promise-returning & async functions with limited concurrency
Expand All @@ -335,7 +327,6 @@ class QueueClass {
- [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 49ac711

Please sign in to comment.