@zkochan/pnpm
Version:
Fast, disk space efficient package manager
126 lines (125 loc) β’ 9.75 kB
JSON
{
"_args": [
[
{
"raw": "p-queue@3.0.0",
"scope": null,
"escapedName": "p-queue",
"name": "p-queue",
"rawSpec": "3.0.0",
"spec": "3.0.0",
"type": "version"
},
"/home/zkochan/src/pnpm/packages/pnpm/node_modules/@pnpm/package-requester"
]
],
"_from": "p-queue@3.0.0",
"_hasShrinkwrap": false,
"_id": "p-queue@3.0.0",
"_location": "/p-queue",
"_nodeVersion": "8.11.4",
"_npmOperationalInternal": {
"host": "s3://npm-registry-packages",
"tmp": "tmp/p-queue_3.0.0_1535535469383_0.009100353604930334"
},
"_npmUser": {
"name": "sindresorhus",
"email": "sindresorhus@gmail.com"
},
"_npmVersion": "5.6.0",
"_phantomChildren": {},
"_requested": {
"raw": "p-queue@3.0.0",
"scope": null,
"escapedName": "p-queue",
"name": "p-queue",
"rawSpec": "3.0.0",
"spec": "3.0.0",
"type": "version"
},
"_requiredBy": [
"/@pnpm/package-requester"
],
"_resolved": "https://registry.npmjs.org/p-queue/-/p-queue-3.0.0.tgz",
"_shasum": "0ef247082f0dd5a21b66e2cfe8fb7b06db13fb52",
"_shrinkwrap": null,
"_spec": "p-queue@3.0.0",
"_where": "/home/zkochan/src/pnpm/packages/pnpm/node_modules/@pnpm/package-requester",
"bugs": {
"url": "https://github.com/sindresorhus/p-queue/issues"
},
"dependencies": {},
"description": "Promise queue with concurrency control",
"devDependencies": {
"ava": "^0.25.0",
"benchmark": "^2.1.2",
"delay": "^3.1.0",
"in-range": "^1.0.0",
"random-int": "^1.0.0",
"time-span": "^2.0.0",
"xo": "^0.22.0"
},
"directories": {},
"dist": {
"integrity": "sha512-2tv/MRmPXfmfnjLLJAHl+DdU8p2DhZafAnlpm/C/T5BpF5L9wKz5tMin4A4N2zVpJL2YMhPlRmtO7s5EtNrjfA==",
"shasum": "0ef247082f0dd5a21b66e2cfe8fb7b06db13fb52",
"tarball": "https://registry.npmjs.org/p-queue/-/p-queue-3.0.0.tgz",
"fileCount": 4,
"unpackedSize": 13950,
"npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbhmltCRA9TVsSAnZWagAAAOoP/1LVo8EJ5j9KpvKv/kPX\n7twhLQWsvKQC9xmhkYWLMXvd1J2Dz79zLvT5vbWmJR73I5Shy+ekxUYBeWUS\nTL9wt2EQX5XWx3S5KNeJyFu6phxFzHpSFMZGPCqCporaM2XTZ+v/BoV4g0GI\nWv3lOd0+dKTEMwC5ownkmzr6oOQ5Ak89RwNiatWzZW1YE7fydxZwD5KUz8oD\nA4gK6Qvjpa5H+Nyz+rFtZ6gij7ZDHZPGBzKB4Tu4BPp1cB2YZ2/J8nmBYTad\nztTIRQMLSrHQW4QQOJId04UcglUCHzxPgfaw2b/z1qJhvrSL5Lz7LEX1tNQM\nFkNfsutctu0WDLEIxD4UAoE2Ov44JVKR8UC7ROWUzhDVHzIcG2HJcf10hI2k\nu3g9I5e0pv4aiDlZWXAi5bdynYMwN5B1jeBZCQJX9PgDN2lfvCEOMHALKhMk\n5hFfszN78OxTrvey0QPZ3RBhFqtiiKWmqfyG/+XwS5ykyNzJZLAY3DPmonul\nzaxj6r7KmiBxguLngFXCP8JPJVlPHicrVlMma4nBli0s+PmtYfG6/22taIU2\nWkUCzhxLOYQRaS1KaBiRi2cijDl71574INmjo3PVTU8im+TEo6IfBI+JZ3Ou\nnFBYboQXKJngeOFAZZ8GmdMn0tfdKIsrfmQRO8jPKEhf6OwyOETahN8I/VoP\ny7Yi\r\n=ch1P\r\n-----END PGP SIGNATURE-----\r\n"
},
"engines": {
"node": ">=6"
},
"files": [
"index.js"
],
"gitHead": "ae9c8d0e3feafac1985f5afad252cf2f469dbeea",
"homepage": "https://github.com/sindresorhus/p-queue#readme",
"keywords": [
"promise",
"queue",
"enqueue",
"limit",
"limited",
"concurrency",
"throttle",
"throat",
"rate",
"batch",
"ratelimit",
"priority",
"priorityqueue",
"fifo",
"job",
"task",
"async",
"await",
"promises",
"bluebird"
],
"license": "MIT",
"maintainers": [
{
"name": "floatdrop",
"email": "floatdrop@gmail.com"
},
{
"name": "sindresorhus",
"email": "sindresorhus@gmail.com"
}
],
"name": "p-queue",
"optionalDependencies": {},
"readme": "# p-queue [](https://travis-ci.org/sindresorhus/p-queue)\n\n> Promise queue with concurrency control\n\nUseful for rate-limiting async (or sync) operations. For example, when interacting with a REST API or when doing CPU/memory intensive tasks.\n\n\n## Install\n\n```\n$ npm install p-queue\n```\n\n\n## Usage\n\nHere we run only one promise at the time. For example, set `concurrency` to 4 to run four promises at the same time.\n\n```js\nconst PQueue = require('p-queue');\nconst got = require('got');\n\nconst queue = new PQueue({concurrency: 1});\n\nqueue.add(() => got('sindresorhus.com')).then(() => {\n\tconsole.log('Done: sindresorhus.com');\n});\n\nqueue.add(() => got('ava.li')).then(() => {\n\tconsole.log('Done: ava.li');\n});\n\ngetUnicornTask().then(task => queue.add(task)).then(() => {\n\tconsole.log('Done: Unicorn task');\n});\n```\n\n\n## API\n\n### PQueue([options])\n\nReturns a new `queue` instance.\n\n#### options\n\nType: `Object`\n\n##### concurrency\n\nType: `number`<br>\nDefault: `Infinity`<br>\nMinimum: `1`\n\nConcurrency limit.\n\n##### autoStart\n\nType: `boolean`<br>\nDefault: `true`\n\nWhether queue tasks within concurrency limit, are auto-executed as soon as they're added.\n\n##### queueClass\n\nType: `Function`\n\nClass with a `enqueue` and `dequeue` method, and a `size` getter. See the [Custom QueueClass](#custom-queueclass) section.\n\n##### intervalCap\n\nType: `number`<br>\nDefault: `Infinity`<br>\nMinimum: `1`\n\nThe max number of runs in the given interval of time.\n\n##### interval\n\nType: `number`<br>\nDefault: `0`<br>\nMinimum: `0`\n\nThe length of time in milliseconds before the interval count resets. Must be finite.\n\n##### carryoverConcurrencyCount\n\nType: `boolean`<br>\nDefault: `false`\n\nWhether the task must finish in the given interval or will be carried over into the next interval count.\n\n### queue\n\n`PQueue` instance.\n\n#### .add(fn, [options])\n\nAdds a sync or async task to the queue. Always returns a promise.\n\n##### fn\n\nType: `Function`\n\nPromise-returning/async function.\n\n#### options\n\nType: `Object`\n\n##### priority\n\nType: `number`<br>\nDefault: `0`\n\nPriority of operation. Operations with greater priority will be scheduled first.\n\n#### .addAll(fns, [options])\n\nSame as `.add()`, but accepts an array of sync or async functions and returns a promise that resolves when all functions are resolved.\n\n#### .pause()\n\nPut queue execution on hold.\n\n#### .start()\n\nStart (or resume) executing enqueued tasks within concurrency limit. No need to call this if queue is not paused (via `options.autoStart = false` or by `.pause()` method.)\n\n#### .onEmpty()\n\nReturns a promise that settles when the queue becomes empty.\n\nCan be called multiple times. Useful if you for example add additional items at a later time.\n\n#### .onIdle()\n\nReturns a promise that settles when the queue becomes empty, and all promises have completed; `queue.size === 0 && queue.pending === 0`.\n\nThe difference with `.onEmpty` is that `.onIdle` guarantees that all work from the queue has finished. `.onEmpty` merely signals that the queue is empty, but it could mean that some promises haven't completed yet.\n\n#### .clear()\n\nClear the queue.\n\n#### .size\n\nSize of the queue.\n\n#### .pending\n\nNumber of pending promises.\n\n#### .isPaused\n\nWhether the queue is currently paused.\n\n## Advanced example\n\nA more advanced example to help you understand the flow.\n\n```js\nconst delay = require('delay');\nconst PQueue = require('p-queue');\n\nconst queue = new PQueue({concurrency: 1});\n\ndelay(200).then(() => {\n\tconsole.log(`8. Pending promises: ${queue.pending}`);\n\t//=> '8. Pending promises: 0'\n\n\tqueue.add(() => Promise.resolve('π')).then(console.log.bind(null, '11. Resolved'));\n\n\tconsole.log('9. Added π');\n\n\tconsole.log(`10. Pending promises: ${queue.pending}`);\n\t//=> '10. Pending promises: 1'\n\n\tqueue.onIdle().then(() => {\n\t\tconsole.log('12. All work is done');\n\t});\n});\n\nqueue.add(() => Promise.resolve('π¦')).then(console.log.bind(null, '5. Resolved'));\nconsole.log('1. Added π¦');\n\nqueue.add(() => Promise.resolve('π΄')).then(console.log.bind(null, '6. Resolved'));\nconsole.log('2. Added π΄');\n\nqueue.onEmpty().then(() => {\n\tconsole.log('7. Queue is empty');\n});\n\nconsole.log(`3. Queue size: ${queue.size}`);\n//=> '3. Queue size: 1`\nconsole.log(`4. Pending promises: ${queue.pending}`);\n//=> '4. Pending promises: 1'\n```\n\n```\n$ node example.js\n1. Added π¦\n2. Added π΄\n3. Queue size: 1\n4. Pending promises: 1\n5. Resolved π¦\n6. Resolved π΄\n7. Queue is empty\n8. Pending promises: 0\n9. Added π\n10. Pending promises: 1\n11. Resolved π\n12. All work is done\n```\n\n\n## Custom QueueClass\n\nFor implementing more complex scheduling policies, you can provide a QueueClass in the options:\n\n```js\nclass QueueClass {\n\tconstructor() {\n\t\tthis._queue = [];\n\t}\n\tenqueue(run, options) {\n\t\tthis._queue.push(run);\n\t}\n\tdequeue() {\n\t\treturn this._queue.shift();\n\t}\n\tget size() {\n\t\treturn this._queue.length;\n\t}\n}\n```\n\n`p-queue` will call corresponding methods to put and get operations from this queue.\n\n\n## Related\n\n- [p-limit](https://github.com/sindresorhus/p-limit) - Run multiple promise-returning & async functions with limited concurrency\n- [p-throttle](https://github.com/sindresorhus/p-throttle) - Throttle promise-returning & async functions\n- [p-debounce](https://github.com/sindresorhus/p-debounce) - Debounce promise-returning & async functions\n- [p-all](https://github.com/sindresorhus/p-all) - Run promise-returning & async functions concurrently with optional limited concurrency\n- [Moreβ¦](https://github.com/sindresorhus/promise-fun)\n\n\n## License\n\nMIT\n",
"readmeFilename": "readme.md",
"repository": {
"type": "git",
"url": "git+https://github.com/sindresorhus/p-queue.git"
},
"scripts": {
"bench": "node bench.js",
"test": "xo && ava"
},
"version": "3.0.0"
}