{"name":"grouped-queue","version":"2.0.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"},"gitHead":"bd05f9fbed77a77a3020385de7cf7ba932645ab8","bugs":{"url":"https://github.com/SBoudrias/grouped-queue/issues"},"homepage":"https://github.com/SBoudrias/grouped-queue#readme","_id":"grouped-queue@2.0.0","_nodeVersion":"14.15.4","_npmVersion":"6.14.11","dist":{"integrity":"sha512-/PiFUa7WIsl48dUeCvhIHnwNmAAzlI/eHoJl0vu3nsFA366JleY7Ff8EVTplZu5kO0MIdZjKTTnzItL61ahbnw==","shasum":"a2c6713f2171e45db2c300a3a9d7c119d694dac8","tarball":"http://registry-npm.ywwl.com/grouped-queue/download/grouped-queue-2.0.0.tgz","fileCount":4,"unpackedSize":8203,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgFJZQCRA9TVsSAnZWagAAurcP/ilhiEXZHnjAvSLxv9LF\nfLOvNWPFfocpRLprVMfe8gcqIc5zyfsYxqL7xD3KyvI8Pz7HHIotXjoxZTJN\nMxWreoGlj+Dvh/1RdplVi6Ni3+s0x5bmEWqekoauuRWwaQPfvV+KzdqI6tcs\nyJWxnkwjVyCT7xsoiXuTaET63yvHr6nvcfaL1MC88EmZZJxLQ8XTQGdTfaES\n1y6aW7R7Jmfc9VRlkAE4bJ1FDZ8n3Ruet7yQuJ+Ar9Ld9VNicRTqHFiw4M+I\nySIdikvFrN3E+3e1purZE7YLmF6xXIzTu/t3CUZD4X/I0yyWozJycFpyQso3\nrMUMbDyRUJH5+s8+sQB9kFMjNEiz0UJtl3XxOjE3S0N66p+KpQRaPZCG3DVp\nrj0m9pYS83N+JduIeyzlQnq7R/EZ9KLIkRPa/TPQXUkR1NDJH9yJcMBCsGUw\nNksTMkAHGzmvrZ5Mx5GVSaL+2nEbNNjgQZNNd336ySHJJYgcvPb5JSb6WARN\n0/YmtSObDkQjSLCys1Sz/R96qrghz8Zjy7fTsojE6HrwOEE0h7TodxG0zlzV\nSOd4sPncDTFS8yU80oNCWz1FCew3V01ShojKgBHsLif7qacGDlaLSxrzXdzZ\n9BwacT3U621AQOXtXIZgNAbJwOGfnf08d0SKV5i8aWpK1yvd0G8CtZILzHVS\nRxY2\r\n=DK1h\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCHS1cvjj3guXfkzdKlRlQzNNQgA3qqta8BcqZdbJihXQIhAJ0w6Aos1grn6rr+shpyxlbvYuPQCNoDgVRzg742Ccx4"}],"size":3262,"noattachment":false,"key":"/grouped-queue/-/grouped-queue-2.0.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_1611961935626_0.8420910538686923"},"_hasShrinkwrap":false,"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","publish_time":1611961935815,"_cnpm_publish_time":1611961935815,"dist-tags":{"latest":"2.1.0","next-2":"2.0.0-beta.2"}}