diff --git a/package.json b/package.json index 988abf7..b0d7c8b 100644 --- a/package.json +++ b/package.json @@ -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" diff --git a/readme.md b/readme.md index 89d9951..eb11449 100644 --- a/readme.md +++ b/readme.md @@ -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. @@ -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 () => { @@ -39,7 +37,6 @@ const queue = new PQueue({concurrency: 1}); })(); ``` - ## API ### PQueue(options?) @@ -166,7 +163,6 @@ Clear the queue. Size of the queue. - #### .sizeBy(options) Size of the queue, filtered by the given options. @@ -199,7 +195,6 @@ Number of pending promises. Whether the queue is currently paused. - ## Events #### active @@ -224,7 +219,6 @@ queue.add(() => Promise.resolve()); queue.add(() => delay(500)); ``` - ## Advanced example A more advanced example to help you understand the flow. @@ -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: @@ -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 @@ -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) - ---