{"name":"grouped-queue","version":"2.0.0-beta.0","description":"In memory queue system prioritizing tasks","main":"lib/queue.js","scripts":{"test":"mocha -R spec"},"repository":{"type":"git","url":"git+https://github.com/SBoudrias/grouped-queue.git"},"keywords":["queue","async","task","flow","control"],"author":{"name":"Simon Boudrias","email":"admin@simonboudrias.com"},"license":"MIT","engines":{"node":">=8.0.0"},"devDependencies":{"mocha":"^8.0.1","sinon":"^9.0.2"},"readme":"Grouped Queue [![Build Status](https://travis-ci.org/SBoudrias/grouped-queue.svg?branch=master)](https://travis-ci.org/SBoudrias/grouped-queue)\n==============\n\nIn memory queue system prioritizing tasks.\n\n\nDocumentation\n=============\n\nInstallation\n-------------\n\n``` bash\n$ npm install --save grouped-queue\n```\n\nMethods\n------------\n\n### Constructor\n\nThe constructor takes an optional array of task groups. The first `String` name will be the first queue to be emptied, the second string will be the second group emptied, etc.\n\nBy default, the constructor will always add a `default` queue in the last position. You can overwrite the position of the `default` group if you specify it explicitly.\n\n``` javascript\nvar Queue = require('grouped-queue');\n\nvar queue = new Queue([ 'first', 'second', 'third' ]);\n```\n\n### Queue#add `add( [group], task, [options] )`\n\nAdd a task into a group queue. If no group name is specified, `default` will be used.\n\nImplicitly, each time you add a task, the queue will start emptying (if not already running).\n\nEach task function is passed a callback function. This callback must be called when the task is complete.\n\n``` javascript\nqueue.add(function( cb ) {\n  DB.fetch().then( cb );\n});\n```\n\n#### Option: `once`\n\nYou can register tasks in queues that will be dropped if they're already planned. This is done with the `once` option. You pass a String (basically a name) to the `once` option.\n\n``` javascript\n// This one will eventually run\nqueue.add( method, { once: \"readDB\" });\n\n// This one will be dropped as `method` is currently in the queue\nqueue.add( method3, { once: \"readDB\" });\n```\n\n#### Option: `run`\n\nYou can register a task without launching the run loop by passing the argument `run: false`.\n\n```javascript\nqueue.add( method, { run: false });\n```\n\n### Pro tip\n\nBind your tasks with context and arguments!\n\n``` javascript\nvar task = function( models, cb ) {\n  /* you get `models` data here! */\n};\nqueue.add( task.bind(null, models) );\n```\n\n### That's all?\n\nYes!\n\nEvents\n-------------\n\n### `end`\n\nThis event is called **each time** the queue emptied itself.\n\n\nContributing\n=====================\n\n**Style Guide**: Please base yourself on [Idiomatic.js](https://github.com/rwldrn/idiomatic.js) style guide with two space indent  \n**Unit test**: Unit tests are written in Mocha. Please add a unit test for every new feature\nor bug fix. `npm test` to run the test suite.  \n**Documentation**: Add documentation for every API change. Feel free to send corrections\nor better docs!  \n**Pull Requests**: Send _fixes_ PR on the `master` branch.\n\n\nLicense\n=====================\n\nCopyright (c) 2013 Simon Boudrias (twitter: @vaxilart)  \nLicensed under the MIT license.\n","readmeFilename":"README.md","gitHead":"f00577c17d8b2bb311dc0db400900bbee19dcaa5","bugs":{"url":"https://github.com/SBoudrias/grouped-queue/issues"},"homepage":"https://github.com/SBoudrias/grouped-queue#readme","_id":"grouped-queue@2.0.0-beta.0","_nodeVersion":"12.16.3","_npmVersion":"6.14.5","dist":{"integrity":"sha512-w+UNwSwQ/42mpAZ2q5BP7KYGWyZ5DGXo8RW+/UxUyuses7NjuTMUAReN+6IaRH1hqW+Af6kPhTZxUD/cYviDMQ==","shasum":"37f07deea535342831f8c1b70a54dec1421f1b1a","tarball":"http://registry-npm.ywwl.com/grouped-queue/download/grouped-queue-2.0.0-beta.0.tgz","fileCount":4,"unpackedSize":8080,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJftB08CRA9TVsSAnZWagAA4m0P/RMEjRmEqac+BEF705rm\nIWEnWSW4OoWnTC6Suj7s+tqL00FBvHiK31lGbekgRJhBvBId7brUgyKOfedu\nQrX32DnbUZOow1NPz+Eu92mELM7qCVXd0R1bKL8xw53hJk/EnC0bHd/NNDF5\n5UAt3+vIWEZYrQzlhULuiCQDSm6LTWBT3ZP/6vEtkTm5e1373dPPZHY+TUq/\nsWTP7wkm8GqU6n+ykCyVlDA55ujlyLK/88+DCgoIdQxM5KRlhtQgHJtz8hhD\nttRk/pJjBvqYeiuHWaxAS+n1wPmkIxysmDfEea37Py+NM/cYgwD8iqVuJhut\np+nMBDp9Gyro1VsTcT1VfefVnMmcegm+Ea/xZ1mtsOHC+Wd1Ozfyk0igh32R\n8gBehoJxRfztwDb37UKBqggquo7SN7sD3crstw7VBQr22Ws76/yMS+e1LDPh\n+aWiMcms695N4VF+xBImiQpihUEZK/Qs1NopwgS8jQe/OW4trr0/972ztxzP\nD4J/MT/ipECIykniuCtY4BcAlY8NUV/vR/C6BomfjsVOUfqprVGk4yYN3fsp\n0JYXoUn8iLrmt4AzeJlzVOX8QgTpxxjaYi0Bd46Q1BMRFy9up2s1uq43gebF\n2bhKFF3p4qv0aVZ8000xmaabQr8koejQu9hcFsiRtkmC+K98PpHmNKtu6qkN\n/0q6\r\n=5ne0\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIC5wEWZoJzE6Me3qoMd+xhX1QnNCqSIWZSgWbtY5qIIGAiAWrhUBwZ36Z1X9sdZ1ztt4XMIarmiEJ4ogPyL+K/m/BQ=="}],"size":3242,"noattachment":false,"key":"/grouped-queue/-/grouped-queue-2.0.0-beta.0.tgz"},"_npmUser":{"name":"mshima","email":"marceloshima@gmail.com"},"directories":{},"maintainers":[{"name":"sboudrias","email":"admin@simonboudrias.com"},{"name":"mshima","email":"marceloshima@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/grouped-queue_2.0.0-beta.0_1605639484025_0.4561980579857692"},"_hasShrinkwrap":false,"publish_time":1605639484202,"_cnpm_publish_time":1605639484202,"dist-tags":{"latest":"2.1.0","next-2":"2.0.0-beta.2"}}