{
  "_args": [
    [
      {
        "raw": "p-queue@5.0.0",
        "scope": null,
        "escapedName": "p-queue",
        "name": "p-queue",
        "rawSpec": "5.0.0",
        "spec": "5.0.0",
        "type": "version"
      },
      "/home/zoltan/src/pnpm/pnpm/packages/pnpm/node_modules/@pnpm/package-requester"
    ]
  ],
  "_from": "p-queue@5.0.0",
  "_hasShrinkwrap": false,
  "_id": "p-queue@5.0.0",
  "_location": "/p-queue",
  "_nodeVersion": "10.15.1",
  "_npmOperationalInternal": {
    "host": "s3://npm-registry-packages",
    "tmp": "tmp/p-queue_5.0.0_1554549304348_0.5687749551962844"
  },
  "_npmUser": {
    "name": "sindresorhus",
    "email": "sindresorhus@gmail.com"
  },
  "_npmVersion": "6.4.1",
  "_phantomChildren": {},
  "_requested": {
    "raw": "p-queue@5.0.0",
    "scope": null,
    "escapedName": "p-queue",
    "name": "p-queue",
    "rawSpec": "5.0.0",
    "spec": "5.0.0",
    "type": "version"
  },
  "_requiredBy": [
    "/@pnpm/package-requester"
  ],
  "_resolved": "https://registry.npmjs.org/p-queue/-/p-queue-5.0.0.tgz",
  "_shasum": "80f1741d5e78a6fa72fce889406481baa5617a3c",
  "_shrinkwrap": null,
  "_spec": "p-queue@5.0.0",
  "_where": "/home/zoltan/src/pnpm/pnpm/packages/pnpm/node_modules/@pnpm/package-requester",
  "bugs": {
    "url": "https://github.com/sindresorhus/p-queue/issues"
  },
  "dependencies": {
    "eventemitter3": "^3.1.0"
  },
  "description": "Promise queue with concurrency control",
  "devDependencies": {
    "@types/node": "^11.13.0",
    "ava": "^1.4.1",
    "benchmark": "^2.1.4",
    "codecov": "^3.3.0",
    "delay": "^4.1.0",
    "in-range": "^1.0.0",
    "nyc": "^13.3.0",
    "random-int": "^1.0.0",
    "time-span": "^2.0.0",
    "tsd": "^0.7.2",
    "xo": "^0.24.0"
  },
  "directories": {},
  "dist": {
    "integrity": "sha512-6QfeouDf236N+MAxHch0CVIy8o/KBnmhttKjxZoOkUlzqU+u9rZgEyXH3OdckhTgawbqf5rpzmyR+07+Lv0+zg==",
    "shasum": "80f1741d5e78a6fa72fce889406481baa5617a3c",
    "tarball": "https://registry.npmjs.org/p-queue/-/p-queue-5.0.0.tgz",
    "fileCount": 5,
    "unpackedSize": 19102,
    "npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcqIo5CRA9TVsSAnZWagAAVHQP/AiozkndVMXczCuw+5lg\nt29lxJmodK8KZU+oiEstQ56NldnmT7swpr/dHealxSr6GmLb6Xl3G6ytGgIW\n/SjOqaUpVUbzipibpJnVZwOK2mEbYnLnSgTfh1wGA4vxM8nLcHKiautHycNv\nNrIyBGbmdTC6uHLshkmoETlbRT60R6F80T0HVEgMvtptAK0ELoCxc3Io2V2O\neAKE8vozD9MQgizu+CQITArIDAlBQ7EFR6/WUH58QmvKW8PkSCivkMeFQcrC\npQxaspn0pa89YrI8Jm1IWDQfA88Mu/gCE7o24DYc0p/dlt2f8gTU2XI/zRP0\nV6St/pLfSLcvEjtV4eNQpU4sKrWzcnDxdl5/gXlVX5Jrs7Vz5dN6MczuWPFn\n6pF1OTE0VJh/NY/zyF2qLiDoPt4WyGd6LOsWoH+rlfXslNSMzxVfhdpZgEBG\nq6VS7DL3QHuhzyq2ZKVmShVPIVMa+8F1aKkUTg1AvIJ06Ye9rnpdyQ1DSzzc\nKhiBHsBsoVytMUkacddNUyBY8Z7TcWIvVTlvEScBjx9gWbwPoa9nr9IgnChD\nTAlNKQvBlJPXYtsqwor54sG3uWfaNls3aVyW32F1CWEiFoa+hYP7O0olkio9\n11T0LpODea+I76dyGct5x361NpXfwfss5/vmtLIFqIqls3NsQal7l7Kzm6Yp\n5tzb\r\n=4Dha\r\n-----END PGP SIGNATURE-----\r\n"
  },
  "engines": {
    "node": ">=8"
  },
  "files": [
    "index.js",
    "index.d.ts"
  ],
  "gitHead": "18040fecaacad375b5a46751f56131ba32104daf",
  "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 [![Build Status](https://travis-ci.org/sindresorhus/p-queue.svg?branch=master)](https://travis-ci.org/sindresorhus/p-queue) [![codecov](https://codecov.io/gh/sindresorhus/p-queue/branch/master/graph/badge.svg)](https://codecov.io/gh/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\n(async () => {\n\tawait queue.add(() => got('sindresorhus.com'));\n\tconsole.log('Done: sindresorhus.com');\n})();\n\n(async () => {\n\tawait queue.add(() => got('ava.li'));\n\tconsole.log('Done: ava.li');\n})();\n\n(async () => {\n\tconst task = await getUnicornTask();\n\tawait queue.add(task);\n\tconsole.log('Done: Unicorn task');\n})();\n```\n\n\n## API\n\n### PQueue([options])\n\nReturns a new `queue` instance, which is an [`EventEmitter3`](https://github.com/primus/eventemitter3) subclass.\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\n## Events\n\n#### active\n\nEmitted as each item is processed in the queue for the purpose of tracking progress.\n\n```js\nconst delay = require('delay');\nconst PQueue = require('p-queue');\n\nconst queue = new PQueue({concurrency: 2});\n\nlet count = 0;\nqueue.on('active', () => {\n\tconsole.log(`Working on item #${++count}.  Size: ${queue.size}  Pending: ${queue.pending}`);\n});\n\nqueue.add(() => Promise.resolve());\nqueue.add(() => delay(2000));\nqueue.add(() => Promise.resolve());\nqueue.add(() => Promise.resolve());\nqueue.add(() => delay(500));\n```\n\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\n(async () => {\n\tawait delay(200);\n\n\tconsole.log(`8. Pending promises: ${queue.pending}`);\n\t//=> '8. Pending promises: 0'\n\n\t(async () => {\n\t\tawait queue.add(async () => '🐙');\n\t\tconsole.log('11. Resolved')\n\t})();\n\n\tconsole.log('9. Added 🐙');\n\n\tconsole.log(`10. Pending promises: ${queue.pending}`);\n\t//=> '10. Pending promises: 1'\n\n\tawait queue.onIdle();\n\tconsole.log('12. All work is done');\n})();\n\n(async () => {\n\tawait queue.add(async () => '🦄');\n\tconsole.log('5. Resolved')\n})();\nconsole.log('1. Added 🦄');\n\n(async () => {\n\tawait queue.add(async () => '🐴');\n\tconsole.log('6. Resolved')\n})();\nconsole.log('2. Added 🐴');\n\n(async () => {\n\tawait queue.onEmpty();\n\tconsole.log('7. Queue is empty');\n})();\n\nconsole.log(`3. Queue size: ${queue.size}`);\n//=> '3. Queue size: 1`\n\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 && nyc ava && tsd"
  },
  "version": "5.0.0"
}
