{"name":"grouped-queue","version":"2.0.0-beta.1","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":"4c1047b22011fafdd4f26c0698fcca736ce2ed44","bugs":{"url":"https://github.com/SBoudrias/grouped-queue/issues"},"homepage":"https://github.com/SBoudrias/grouped-queue#readme","_id":"grouped-queue@2.0.0-beta.1","_nodeVersion":"12.16.3","_npmVersion":"6.14.5","dist":{"integrity":"sha512-vvUjJvTfpGdwqizixxdMpLg8fArr4RTG7WtiYr7+X4P/o3BWc4yzkeicumPecQbHVrhCwEplti1EA1R9kg9csA==","shasum":"9d4e67ccd3a83c93cda64bb31f26fc2766f54f3b","tarball":"http://registry-npm.ywwl.com/grouped-queue/download/grouped-queue-2.0.0-beta.1.tgz","fileCount":4,"unpackedSize":8179,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJftHtsCRA9TVsSAnZWagAAHVIQAIJYruXdomJckYs1CYiR\naaeDtXTPBZ9cskBUb0l4uy9Gitkw5cNznEUmUAVXyZS4BwdnfjFzZRSo74MF\nCPSExKBf3xiEqRCVGQG163DOmqJ6iWITQmCNIriZPO9IsF+0GwTU6ySjvqnj\nGgGM7OgPiDAKAfOlXuW11qbVkNsIySkaiUeoUK8x/96ARbm+zueSR7kKcIlk\nIxRhzjVtEfEh4r84WDSDsdsqr3VGp6QF1Vv+Adq7Dlx+OmTH6dvp8e6qc38d\nFV4ccF625OstPic4mXjam+ufW5cI4zDMCEFz5Mjr6OgrZubh0w4ArQrAikUD\nEop/Kx1Ogk1o1r4pjQqTyypGHTehqZe2DtaPxz6+8HKDxp1B8T7y9EmmQqoX\njZsW1SdiYSHpjBIUU01d4tECzxrW2lm1Bu2eEL/HZEXWrKnjvYYIkomK8KWf\n50em0vJikSnk2llh4DtsbWP9Za1Tbl556G6VtPrGIqSIRz8QKPjHg7Bp2Fsy\nEsBhn/9c2Oa0Ode1DrEsuMbK97wFDkgiE/mDzs3wF5WqffqoVUqn3G5wJID7\nJ6gVuwCr0vKEy9YC4ThMDtBr6cxkbPDbHPeC7Jn6GncrmO2ZJVguKaYCfIYN\n/ejpB72lzAPSWQjuXyY8sHl7M//yGAmJiq8Gp51a5Yy616z/f+rL8DYKbQJF\n7aJw\r\n=Mbmd\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDBAuTZrA6vwaGc8bbhnjK2JdQ4ZX4upkD9RdlDOpFNXAIhAIfWp2UytMxX3o5ZQiBwleV84sbESq1XWxDj82/GsokG"}],"size":3267,"noattachment":false,"key":"/grouped-queue/-/grouped-queue-2.0.0-beta.1.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.1_1605663596275_0.046418554182270144"},"_hasShrinkwrap":false,"publish_time":1605663596487,"_cnpm_publish_time":1605663596487,"dist-tags":{"latest":"2.1.0","next-2":"2.0.0-beta.2"}}