{"_id":"p-batch","_rev":"14-5029c01ee0cf274b118502a5792b6148","name":"p-batch","description":"Batch async operations","dist-tags":{"latest":"1.0.0"},"versions":{"0.1.0":{"name":"p-batch","version":"0.1.0","description":"Batch async operations","license":"MIT","repository":{"type":"git","url":"git+https://github.com/floatdrop/p-batch.git"},"author":{"name":"Vsevolod Strukchinsky","email":"floatdrop@gmail.com","url":"github.com/floatdrop"},"engines":{"node":">=4"},"scripts":{"bench":"node bench.js","test":"xo && ava"},"files":["index.js"],"keywords":["promise","batch"],"dependencies":{},"devDependencies":{"ava":"*","benchmark":"^2.1.3","dataloader":"^1.3.0","xo":"*"},"gitHead":"e92bc8163ef5da0a95429d27c5e5062edfc65341","bugs":{"url":"https://github.com/floatdrop/p-batch/issues"},"homepage":"https://github.com/floatdrop/p-batch#readme","_id":"p-batch@0.1.0","_shasum":"0a36413d9409e49429861cc3797095ad83db243c","_from":".","_npmVersion":"4.1.2","_nodeVersion":"7.5.0","_npmUser":{"name":"floatdrop","email":"floatdrop@gmail.com"},"dist":{"shasum":"0a36413d9409e49429861cc3797095ad83db243c","tarball":"https://registry.npmjs.org/p-batch/-/p-batch-0.1.0.tgz","integrity":"sha512-oW4rMP+Xa2WpI3W7T63Gen7NC+iTuQg2RxOEDHWjiHjjuKRBK/hgpHNRpS94VLyK0+MHALyDPFK5Ibv+JQGYnw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBVvC6RgHmjzTzzyd/436Rye1yEFYsxNnAJUDF5zkRq2AiBKk7FG4u4D6YKUBuY0rNOK7K1BrlsBA7zGrhyKkTA9Uw=="}]},"maintainers":[{"name":"floatdrop","email":"floatdrop@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/p-batch-0.1.0.tgz_1487357504518_0.5936316710431129"}},"0.1.1":{"name":"p-batch","version":"0.1.1","description":"Batch async operations","license":"MIT","repository":{"type":"git","url":"git+https://github.com/floatdrop/p-batch.git"},"author":{"name":"Vsevolod Strukchinsky","email":"floatdrop@gmail.com","url":"github.com/floatdrop"},"engines":{"node":">=4"},"scripts":{"bench":"node bench.js","test":"xo && ava"},"files":["index.js"],"keywords":["promise","batch"],"dependencies":{},"devDependencies":{"ava":"*","benchmark":"^2.1.3","dataloader":"^1.3.0","xo":"*"},"gitHead":"c5546585d61c1a270ea9dd5682ecf1515cb23be4","bugs":{"url":"https://github.com/floatdrop/p-batch/issues"},"homepage":"https://github.com/floatdrop/p-batch#readme","_id":"p-batch@0.1.1","_shasum":"1a1bfd7abae7227e7415de364982db46ba2c40d4","_from":".","_npmVersion":"4.1.2","_nodeVersion":"7.5.0","_npmUser":{"name":"floatdrop","email":"floatdrop@gmail.com"},"dist":{"shasum":"1a1bfd7abae7227e7415de364982db46ba2c40d4","tarball":"https://registry.npmjs.org/p-batch/-/p-batch-0.1.1.tgz","integrity":"sha512-DovJ59G55C4lb8SGcunhCPkhzY21lMsUnUQBt4Q7PScNZC1DYT/03u6+9t6bYB2oAu6P7AitlGtxj/1cVEAXYA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDPiMuCv4+MHiiqKx3PshaB5s4o650lPNZD9vcU0B9jlAiBuw7E7pQOd70GsQVc2/yZA9b+PTWC6rJkIrnzXYGBtug=="}]},"maintainers":[{"name":"floatdrop","email":"floatdrop@gmail.com"}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/p-batch-0.1.1.tgz_1487358514296_0.8538368113804609"}},"0.2.0":{"name":"p-batch","version":"0.2.0","description":"Batch async operations","license":"MIT","repository":{"type":"git","url":"git+https://github.com/floatdrop/p-batch.git"},"author":{"name":"Vsevolod Strukchinsky","email":"floatdrop@gmail.com","url":"github.com/floatdrop"},"engines":{"node":">=4"},"scripts":{"bench":"node bench.js","test":"xo && ava"},"files":["index.js"],"keywords":["promise","batch"],"dependencies":{},"devDependencies":{"ava":"*","benchmark":"^2.1.3","dataloader":"^1.3.0","xo":"*"},"gitHead":"2a0ce7eaf608eebb1416d791d24cbdcad20f4f44","bugs":{"url":"https://github.com/floatdrop/p-batch/issues"},"homepage":"https://github.com/floatdrop/p-batch#readme","_id":"p-batch@0.2.0","_shasum":"b1bc005cc17d244fcad29ba46baef240d6db4ff2","_from":".","_npmVersion":"4.1.2","_nodeVersion":"7.5.0","_npmUser":{"name":"floatdrop","email":"floatdrop@gmail.com"},"dist":{"shasum":"b1bc005cc17d244fcad29ba46baef240d6db4ff2","tarball":"https://registry.npmjs.org/p-batch/-/p-batch-0.2.0.tgz","integrity":"sha512-19HjvH3KgkSKTEPoCP+SlprOkEYtitphR2sSIWWmSMrFGCDitqJGGwi7vId6HZRN329NRU2Xh4P0292Jk3nJUA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIAN/bsKgvnYarWWYhACDsTlr0S7NQ+Luq7wSOkDPD0+9AiA9Fo2v2XnQg/lt1Z/UF8MeF5387mZqXH2tzcYzk7eAeg=="}]},"maintainers":[{"name":"floatdrop","email":"floatdrop@gmail.com"}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/p-batch-0.2.0.tgz_1487516480352_0.4782604705542326"}},"0.3.0":{"name":"p-batch","version":"0.3.0","description":"Batch async operations","license":"MIT","repository":{"type":"git","url":"git+https://github.com/floatdrop/p-batch.git"},"author":{"name":"Vsevolod Strukchinsky","email":"floatdrop@gmail.com","url":"github.com/floatdrop"},"engines":{"node":">=4"},"scripts":{"bench":"node bench.js","test":"xo && ava"},"files":["index.js"],"keywords":["promise","batch"],"dependencies":{},"devDependencies":{"ava":"*","benchmark":"^2.1.3","dataloader":"^1.3.0","xo":"*"},"gitHead":"95e16e9d0534c3b6476eedcc71aaac23ee5cc8c4","bugs":{"url":"https://github.com/floatdrop/p-batch/issues"},"homepage":"https://github.com/floatdrop/p-batch#readme","_id":"p-batch@0.3.0","_shasum":"25863c046f897e66b48aa01a767af292e78a0057","_from":".","_npmVersion":"4.1.2","_nodeVersion":"7.5.0","_npmUser":{"name":"floatdrop","email":"floatdrop@gmail.com"},"dist":{"shasum":"25863c046f897e66b48aa01a767af292e78a0057","tarball":"https://registry.npmjs.org/p-batch/-/p-batch-0.3.0.tgz","integrity":"sha512-o0H+aXbHiyVEbGga3Q3S+4AquA/58/ICxlQaMRucnKdYA7Ubdk2Qs47o8cQfK03OEwifv31xs90VZaIKY5QiDg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBZo/V6Cd/kLhtw5yrRynzkVHyhw9Gn6BSAphafJJH2qAiBKeXVImWGHQ9zaptHKDI/Zvc8cbP+4GOcEWz5eqQxXBA=="}]},"maintainers":[{"name":"floatdrop","email":"floatdrop@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/p-batch-0.3.0.tgz_1487524276283_0.36196979763917625"}},"0.4.0":{"name":"p-batch","version":"0.4.0","description":"Batch async operations","license":"MIT","repository":{"type":"git","url":"git+https://github.com/floatdrop/p-batch.git"},"author":{"name":"Vsevolod Strukchinsky","email":"floatdrop@gmail.com","url":"github.com/floatdrop"},"engines":{"node":">=4"},"scripts":{"bench":"node bench.js","test":"xo && ava"},"files":["index.js"],"keywords":["promise","batch"],"dependencies":{},"devDependencies":{"ava":"*","benchmark":"^2.1.3","dataloader":"^1.3.0","xo":"*"},"gitHead":"d4f0092f51c0c5b914bfaff08c874fe0fafecec1","bugs":{"url":"https://github.com/floatdrop/p-batch/issues"},"homepage":"https://github.com/floatdrop/p-batch#readme","_id":"p-batch@0.4.0","_shasum":"2eb3dc9d7ccc7fea220fb6caee38ff754c0392e4","_from":".","_npmVersion":"4.1.2","_nodeVersion":"7.5.0","_npmUser":{"name":"floatdrop","email":"floatdrop@gmail.com"},"dist":{"shasum":"2eb3dc9d7ccc7fea220fb6caee38ff754c0392e4","tarball":"https://registry.npmjs.org/p-batch/-/p-batch-0.4.0.tgz","integrity":"sha512-7ghAJAEFgcO0oxrHC5QLnXfCD60qSYVGoPybX9SdYcIRpATMruJ86VAAw37PI0on/XWYqqAxPtS4UQ423NKrwg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCDJmi+Pt6bTUSrtoUiVLckwaRcxOhXnETchCNdnaR+uwIhAObciEVe9D5Tr2Wze50ef6Y2vIxOPyw1idPzqMDzdEH5"}]},"maintainers":[{"name":"floatdrop","email":"floatdrop@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/p-batch-0.4.0.tgz_1487526161515_0.8379935282282531"}},"0.4.1":{"name":"p-batch","version":"0.4.1","description":"Batch async operations","license":"MIT","repository":{"type":"git","url":"git+https://github.com/floatdrop/p-batch.git"},"author":{"name":"Vsevolod Strukchinsky","email":"floatdrop@gmail.com","url":"github.com/floatdrop"},"engines":{"node":">=4"},"scripts":{"bench":"node bench.js","test":"xo && ava"},"files":["index.js"],"keywords":["promise","batch"],"dependencies":{},"devDependencies":{"ava":"*","benchmark":"^2.1.3","dataloader":"^1.3.0","xo":"*"},"gitHead":"b3ec6aa35ce583cad2812dc0d54e4b5660d1337e","bugs":{"url":"https://github.com/floatdrop/p-batch/issues"},"homepage":"https://github.com/floatdrop/p-batch#readme","_id":"p-batch@0.4.1","_shasum":"90d8d8074d2fc9702bdead9426cb00e6f3798bda","_from":".","_npmVersion":"4.1.2","_nodeVersion":"7.5.0","_npmUser":{"name":"floatdrop","email":"floatdrop@gmail.com"},"dist":{"shasum":"90d8d8074d2fc9702bdead9426cb00e6f3798bda","tarball":"https://registry.npmjs.org/p-batch/-/p-batch-0.4.1.tgz","integrity":"sha512-A9egDM7smSUpLmg7PLDfjlLu5mPpxYn95M8/+mXrVY0Rhw05Y00m4m6+hjQ9oYG0FWaoWKw2uD33RZAtXbACeg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAa7tDqidGtSvTXz+Xwfrmyj8b2IOmHI3eFC9UbvBU+xAiEAgcU3auYukfCGk6KpsHTWYda3q92KIX7B0rIq0HuGNk4="}]},"maintainers":[{"name":"floatdrop","email":"floatdrop@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/p-batch-0.4.1.tgz_1487526221931_0.7311981783714145"}},"0.4.2":{"name":"p-batch","version":"0.4.2","description":"Batch async operations","license":"MIT","repository":{"type":"git","url":"git+https://github.com/floatdrop/p-batch.git"},"author":{"name":"Vsevolod Strukchinsky","email":"floatdrop@gmail.com","url":"github.com/floatdrop"},"engines":{"node":">=4"},"scripts":{"bench":"node bench.js","test":"xo && ava"},"files":["index.js"],"keywords":["promise","batch"],"dependencies":{},"devDependencies":{"ava":"*","benchmark":"^2.1.3","dataloader":"^1.3.0","xo":"*"},"gitHead":"62767a220d8422b7104d8f9b25c05fbb3fe69e01","bugs":{"url":"https://github.com/floatdrop/p-batch/issues"},"homepage":"https://github.com/floatdrop/p-batch#readme","_id":"p-batch@0.4.2","_shasum":"f96c8b9c1581877a9b36ba67253290453ff83110","_from":".","_npmVersion":"4.1.2","_nodeVersion":"7.5.0","_npmUser":{"name":"floatdrop","email":"floatdrop@gmail.com"},"dist":{"shasum":"f96c8b9c1581877a9b36ba67253290453ff83110","tarball":"https://registry.npmjs.org/p-batch/-/p-batch-0.4.2.tgz","integrity":"sha512-0qZnUN0KLqfp+qUbKp85ooNxyoIp5/P/kD7YJC1UYhSHgab0sd5H7QbiwSZIlKonNkaRZaIQgYG20s1g6wzEPg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCID+hP7qQsFhzCYLfRMSyMS1CSdsf+We+43o/b/eEWapBAiAEU94VasFxI/JIo/Vw10mB4U86LmSkkhrT0L5B7ayc4g=="}]},"maintainers":[{"name":"floatdrop","email":"floatdrop@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/p-batch-0.4.2.tgz_1487526458714_0.5645805858075619"}},"0.5.0":{"name":"p-batch","version":"0.5.0","description":"Batch async operations","license":"MIT","repository":{"type":"git","url":"git+https://github.com/floatdrop/p-batch.git"},"author":{"name":"Vsevolod Strukchinsky","email":"floatdrop@gmail.com","url":"github.com/floatdrop"},"engines":{"node":">=4"},"scripts":{"bench":"node bench.js","test":"xo && ava"},"files":["index.js"],"keywords":["promise","batch"],"dependencies":{},"devDependencies":{"ava":"*","benchmark":"^2.1.3","dataloader":"^1.3.0","xo":"*"},"gitHead":"f7e8dc61f794fe86d2115aa087fb8bd8365e545f","bugs":{"url":"https://github.com/floatdrop/p-batch/issues"},"homepage":"https://github.com/floatdrop/p-batch#readme","_id":"p-batch@0.5.0","_shasum":"66d484508d3da758a2eb5f9b543743262ce74254","_from":".","_npmVersion":"4.1.2","_nodeVersion":"7.5.0","_npmUser":{"name":"floatdrop","email":"floatdrop@gmail.com"},"dist":{"shasum":"66d484508d3da758a2eb5f9b543743262ce74254","tarball":"https://registry.npmjs.org/p-batch/-/p-batch-0.5.0.tgz","integrity":"sha512-FJIwMkgFf1RWUy7ttbwA+PuHFk9+vzZI8bkTHHdiwAT+fmWXwNBD+CfYd5jSO9/DYZVchmPNd8angpwkoEZu2w==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGsrsMROos4S1aPyywAZ+bqawCeTo8DUSocxZWBrYZARAiB+GvbaGbcI7i1hRwZHQ19dyO8UQ7k/5JCDEyyFq50HrA=="}]},"maintainers":[{"name":"floatdrop","email":"floatdrop@gmail.com"}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/p-batch-0.5.0.tgz_1487614709307_0.5236199046485126"}},"1.0.0":{"name":"p-batch","version":"1.0.0","description":"Batch async operations","license":"MIT","repository":{"type":"git","url":"git+https://github.com/floatdrop/p-batch.git"},"author":{"name":"Vsevolod Strukchinsky","email":"floatdrop@gmail.com","url":"github.com/floatdrop"},"engines":{"node":">=4"},"scripts":{"bench":"node bench.js","test":"xo && ava"},"files":["index.js"],"keywords":["promise","batch"],"dependencies":{},"devDependencies":{"ava":"*","benchmark":"^2.1.3","dataloader":"^1.3.0","xo":"*"},"gitHead":"7c78f46a317109f4e17a133f35be1b2884b0d266","bugs":{"url":"https://github.com/floatdrop/p-batch/issues"},"homepage":"https://github.com/floatdrop/p-batch#readme","_id":"p-batch@1.0.0","_shasum":"3e8e96518115202c554947a1f6850a1a32b455fa","_from":".","_npmVersion":"4.1.2","_nodeVersion":"7.5.0","_npmUser":{"name":"floatdrop","email":"floatdrop@gmail.com"},"dist":{"shasum":"3e8e96518115202c554947a1f6850a1a32b455fa","tarball":"https://registry.npmjs.org/p-batch/-/p-batch-1.0.0.tgz","integrity":"sha512-UpdxvHv1B9k4L7XHfKLHn5XY8UGCL6M2w9BdP24ywkl26Zx1HRszzqwvX3Sg8MVMbDv+ihuoarFnu+boDIUodA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDFqDOpQQKkzvM7NaIKyUldE/12iJTpVp3h0nw7noM/6AiEA3MfyB0J/z+YOiIX8ZQoVpmWMrMOVwmqqsl+UPvOcoWo="}]},"maintainers":[{"name":"floatdrop","email":"floatdrop@gmail.com"}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/p-batch-1.0.0.tgz_1487654083613_0.5293249764945358"}}},"readme":"# p-batch [![Build Status](https://travis-ci.org/floatdrop/p-batch.svg?branch=master)](https://travis-ci.org/floatdrop/p-batch)\n\n> Batch async operations\n\nUseful, when you have batch endpoint (that can accept multiple queries at once) and want to group requests to this endpoint in parallel user requests.\n\n## Install\n\n```\n$ npm install --save p-batch\n```\n\n\n## Usage\n\n```js\nconst PBatch = require('p-batch');\n\nbatch = new PBatch(keys => {\n\tconsole.log('Batching', keys);\n\treturn keys.map(k => k + 1);\n}, {\n\tmaxBatchSize: 3\n});\n\nconst results = await Promise.all([1, 2, 3, 4, 5].map(key => batch.add(key));\n\n// first logs \"Batching [1, 2, 3]\"\n// then       \"Batching [4, 5]\"\n// results will contain [2, 3, 4, 5, 6]\n```\n\n\n## API\n\n### PBatch(loader, [options])\n\nReturns a new `batch` instance.\n\n#### loader\n\nType: `Function`\n\nLoader function. Accepts array of batched keys and returns array of results or throws with array of errors (or plain error, that will propagate to all promises).\n\n#### options\n\n##### maxBatchSize\n\nType: `number`<br>\nDefault: `Infinity`\n\nMaximum batch size.\n\n##### dispatchSignal\n\nType: `Function`<br>\nDefault: `fn => process.nextTick(fn)`\n\nExecuted after first key put in batch. It should call it's first argument, when it is time for dispatching.\n\nUseful, if you need to wait constant time after last key batching for ex.\n\n### batch\n\n`PBatch` instance.\n\n#### .add(key)\n\nAdds key to current batch. If batch is empty – schedules dispatch on next tick.\n\n#### .addAll(keys)\n\nShortcut for `Promise.all(keys.map(key => batch.add(key)))`.\n\n#### .dispatch()\n\nRuns `loader` on batched keys. Useful, when batch should be dispatched right now.\n\nBy default current batch will be dispatched on next tick.\n\n\n## License\n\nMIT © [Vsevolod Strukchinsky](http://github.com/floatdrop)\n","maintainers":[{"name":"floatdrop","email":"floatdrop@gmail.com"}],"time":{"modified":"2022-06-23T05:42:18.467Z","created":"2017-02-17T18:51:46.492Z","0.1.0":"2017-02-17T18:51:46.492Z","0.1.1":"2017-02-17T19:08:34.872Z","0.2.0":"2017-02-19T15:01:20.925Z","0.3.0":"2017-02-19T17:11:18.208Z","0.4.0":"2017-02-19T17:42:43.392Z","0.4.1":"2017-02-19T17:43:43.923Z","0.4.2":"2017-02-19T17:47:40.595Z","0.5.0":"2017-02-20T18:18:29.851Z","1.0.0":"2017-02-21T05:14:44.177Z"},"homepage":"https://github.com/floatdrop/p-batch#readme","keywords":["promise","batch"],"repository":{"type":"git","url":"git+https://github.com/floatdrop/p-batch.git"},"author":{"name":"Vsevolod Strukchinsky","email":"floatdrop@gmail.com","url":"github.com/floatdrop"},"bugs":{"url":"https://github.com/floatdrop/p-batch/issues"},"license":"MIT","readmeFilename":"readme.md"}