Skip to content

Commit

Permalink
Improve docs
Browse files Browse the repository at this point in the history
Fixes #121
  • Loading branch information
sindresorhus committed Jan 8, 2021
1 parent 9e94070 commit 7036650
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
14 changes: 12 additions & 2 deletions readme.md
Expand Up @@ -161,7 +161,7 @@ Clear the queue.

#### .size

Size of the queue.
Size of the queue, the number of queued items waiting to run.

#### .sizeBy(options)

Expand All @@ -185,7 +185,7 @@ console.log(queue.sizeBy({priority: 0}));

#### .pending

Number of pending promises.
Number of running items (no longer in the queue).

#### [.timeout](#timeout)

Expand Down Expand Up @@ -375,10 +375,20 @@ class QueueClass {
return this._queue;
}
}

const queue = new PQueue({
queueClass: QueueClass
});
```

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

## FAQ

#### How do the `concurrency` and `intervalCap` options affect each other?

They are just different constraints. The `concurrency` option limits how many things run at the same time. The `intervalCap` option limits how many things run in total during the interval (over time).

## Related

- [p-limit](https://github.com/sindresorhus/p-limit) - Run multiple promise-returning & async functions with limited concurrency
Expand Down
4 changes: 2 additions & 2 deletions source/index.ts
Expand Up @@ -349,7 +349,7 @@ export default class PQueue<QueueType extends Queue<RunFunction, EnqueueOptionsT
}

/**
Size of the queue.
Size of the queue, the number of queued items waiting to run.
*/
get size(): number {
return this._queue.size;
Expand All @@ -366,7 +366,7 @@ export default class PQueue<QueueType extends Queue<RunFunction, EnqueueOptionsT
}

/**
Number of pending promises.
Number of running items (no longer in the queue).
*/
get pending(): number {
return this._pendingCount;
Expand Down

0 comments on commit 7036650

Please sign in to comment.