{"_id":"work-batcher","_rev":"26-d48c5bea8ca5a387c04f28399bf0c235","name":"work-batcher","description":"Aggregates payloads/work parcels together so they can be handled in one go. E.g. use to make one request to an API where payload can be stuffed with multiple items.","dist-tags":{"latest":"3.0.0"},"versions":{"0.0.0":{"name":"work-batcher","version":"0.0.0","description":"node-batch ==========","main":"index.js","directories":{"test":"test"},"dependencies":{"async":"^0.9.0"},"devDependencies":{"expect.js":"^0.3.1"},"scripts":{"test":"mocha --recursive test"},"repository":{"type":"git","url":"https://github.com/noblesamurai/node-batch.git"},"author":{"name":"Timothy Leslie Allen","email":"allen.timothy.email@gmail.com","url":"https://github.com/timlesallen"},"license":"ISC","bugs":{"url":"https://github.com/noblesamurai/node-batch/issues"},"homepage":"https://github.com/noblesamurai/node-batch","gitHead":"226d7bc1961c059d3d182d4fd6ca478b27cef3b0","_id":"work-batcher@0.0.0","_shasum":"ffd1434286cf5674d00ea17512f152e50d56146e","_from":".","_npmVersion":"1.4.13","_npmUser":{"name":"timlesallen","email":"allen.timothy.email@gmail.com"},"maintainers":[{"name":"timlesallen","email":"allen.timothy.email@gmail.com"}],"dist":{"shasum":"ffd1434286cf5674d00ea17512f152e50d56146e","tarball":"https://registry.npmjs.org/work-batcher/-/work-batcher-0.0.0.tgz","integrity":"sha512-DgRmwEXhTc9SpoH8u8jZo2rO1LBzgxg1gD3sGywDUUS/tDCfDpHoNRCKaah0dBiRI6mCfo7UiSElVNen57ICCQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGlR7tBm96W8eLPBf8wgbffT15RQh+H5eecZy/cQoSdnAiEA0Sa7dfp7t4JLRMnczUVm8NMIPNpv6L1H6uuAlrsVDnY="}]}},"0.0.1":{"name":"work-batcher","version":"0.0.1","description":"node-batch ==========","main":"index.js","directories":{"test":"test"},"dependencies":{"async":"^0.9.0"},"devDependencies":{"expect.js":"^0.3.1"},"scripts":{"test":"mocha --recursive test"},"repository":{"type":"git","url":"https://github.com/noblesamurai/node-batch.git"},"author":{"name":"Timothy Leslie Allen","email":"allen.timothy.email@gmail.com","url":"https://github.com/timlesallen"},"license":"ISC","bugs":{"url":"https://github.com/noblesamurai/node-batch/issues"},"homepage":"https://github.com/noblesamurai/node-batch","gitHead":"28bc5c5509f353ec2030d54b53c840e4b14b5a23","_id":"work-batcher@0.0.1","_shasum":"a08e9a395e3fd82aff19575a257ac7f3bab98ee7","_from":".","_npmVersion":"1.4.13","_npmUser":{"name":"timlesallen","email":"allen.timothy.email@gmail.com"},"maintainers":[{"name":"timlesallen","email":"allen.timothy.email@gmail.com"}],"dist":{"shasum":"a08e9a395e3fd82aff19575a257ac7f3bab98ee7","tarball":"https://registry.npmjs.org/work-batcher/-/work-batcher-0.0.1.tgz","integrity":"sha512-4msjyZTKtEAsobEOsVO9nLnTML7UVyH4iwEv7BhuP6HM6qfOl7EiHtNnK6VKhxECz6GwYj4g+O+VPoYArr50jQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAGGsCHsh9Z/zZwyMDQ1sl828LrlVdSz0154EYBynNm0AiEAvg+ttOfHCOLsVpKf/NkLok7RoTsxm2p/r9W7b8uIbBo="}]}},"1.0.0":{"name":"work-batcher","version":"1.0.0","description":"node-batch ==========","main":"index.js","directories":{"test":"test"},"dependencies":{"async":"^0.9.0"},"devDependencies":{"expect.js":"^0.3.1"},"scripts":{"test":"mocha --recursive test"},"repository":{"type":"git","url":"https://github.com/noblesamurai/node-batch.git"},"author":{"name":"Timothy Leslie Allen","email":"allen.timothy.email@gmail.com","url":"https://github.com/timlesallen"},"license":"ISC","bugs":{"url":"https://github.com/noblesamurai/node-batch/issues"},"homepage":"https://github.com/noblesamurai/node-batch","gitHead":"12f338cd8cd19d291036cc7d100d197bcfe42835","_id":"work-batcher@1.0.0","_shasum":"0a6927bfa277f80e24cb225fc907875cb19ba831","_from":".","_npmVersion":"1.4.13","_npmUser":{"name":"timlesallen","email":"allen.timothy.email@gmail.com"},"maintainers":[{"name":"timlesallen","email":"allen.timothy.email@gmail.com"}],"dist":{"shasum":"0a6927bfa277f80e24cb225fc907875cb19ba831","tarball":"https://registry.npmjs.org/work-batcher/-/work-batcher-1.0.0.tgz","integrity":"sha512-z7SGxEi2v6LGgZlwKaRkD0va0hfJ1OEXS2XH+fvhUYD6bXhr+iUnUn8SMme9t7KGgZmMVqekMnLvMp8grwaoHQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIE6QKdlCSPTZtjkOi5mYjVv4xTNuPJ1yx99UvE0ZAnbtAiBxQFk3yOfMFw17kjOM3QuQTfjDtdZj1dr3pgy1DV052w=="}]}},"1.0.1":{"name":"work-batcher","version":"1.0.1","description":"node-batch ==========","main":"index.js","directories":{"test":"test"},"dependencies":{"async":"^0.9.0"},"devDependencies":{"expect.js":"^0.3.1"},"scripts":{"test":"mocha --recursive test"},"repository":{"type":"git","url":"https://github.com/noblesamurai/node-batch.git"},"author":{"name":"Timothy Leslie Allen","email":"allen.timothy.email@gmail.com","url":"https://github.com/timlesallen"},"license":"ISC","bugs":{"url":"https://github.com/noblesamurai/node-batch/issues"},"homepage":"https://github.com/noblesamurai/node-batch","gitHead":"ddcd01fd96f72fae928eb4b07900cc92d6e5e13c","_id":"work-batcher@1.0.1","_shasum":"13ca4a4488f1f67f0f8cbfa7fee9136db6fe7983","_from":".","_npmVersion":"1.4.13","_npmUser":{"name":"timlesallen","email":"allen.timothy.email@gmail.com"},"maintainers":[{"name":"timlesallen","email":"allen.timothy.email@gmail.com"}],"dist":{"shasum":"13ca4a4488f1f67f0f8cbfa7fee9136db6fe7983","tarball":"https://registry.npmjs.org/work-batcher/-/work-batcher-1.0.1.tgz","integrity":"sha512-il5wZKGi8Lb31n626YYqNJU7XtNH9H4uQnQsy7236LCcpKyBgURIxb2g6qSM09dwnvR7gEyWh/Ez+uWgG3EjhA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIEZ/XAtD/8AQdsphKr/YOhCxuAiPhyJGFGmifVcasJuaAiEAmYsM1f/sBRGsY2O3ZGoae4DuzVadR0l7ft5LieZLVZI="}]}},"2.0.0":{"name":"work-batcher","version":"2.0.0","description":"node-batch ==========","main":"index.js","directories":{"test":"test"},"dependencies":{"async":"^0.9.0","lodash":"^2.4.1"},"devDependencies":{"expect.js":"^0.3.1"},"scripts":{"test":"mocha --recursive test"},"repository":{"type":"git","url":"https://github.com/noblesamurai/node-batch.git"},"author":{"name":"Timothy Leslie Allen","email":"allen.timothy.email@gmail.com","url":"https://github.com/timlesallen"},"license":"ISC","bugs":{"url":"https://github.com/noblesamurai/node-batch/issues"},"homepage":"https://github.com/noblesamurai/node-batch","gitHead":"c0ecbb543015842969779929ef04c75864f1321d","_id":"work-batcher@2.0.0","_shasum":"5a4cb8b6b6b41fdd68794968d4d2652abf9685bc","_from":".","_npmVersion":"1.4.13","_npmUser":{"name":"timlesallen","email":"allen.timothy.email@gmail.com"},"maintainers":[{"name":"timlesallen","email":"allen.timothy.email@gmail.com"}],"dist":{"shasum":"5a4cb8b6b6b41fdd68794968d4d2652abf9685bc","tarball":"https://registry.npmjs.org/work-batcher/-/work-batcher-2.0.0.tgz","integrity":"sha512-DbCoZHd02uLbFdT89ZMEqKVNvcXUx1HcPx2ftcE0VXyS99aCks+zcTHsWjOr1qSMWfFoqbRO+9D9rQD1zLq+IQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGi5IwUcMR1qG6Gvo5d9k02coYb5y5PWStAy/b12Y8idAiEAwUQcph3hkB8fUTnmLQpKowE2W1L9IhhhJVGjCERrbl4="}]}},"2.0.1":{"name":"work-batcher","version":"2.0.1","description":"node-batch ==========","main":"index.js","directories":{"test":"test"},"dependencies":{"async":"^0.9.0","lodash":"^2.4.1"},"devDependencies":{"expect.js":"^0.3.1"},"scripts":{"test":"mocha --recursive test"},"repository":{"type":"git","url":"https://github.com/noblesamurai/node-batch.git"},"author":{"name":"Timothy Leslie Allen","email":"allen.timothy.email@gmail.com","url":"https://github.com/timlesallen"},"license":"ISC","bugs":{"url":"https://github.com/noblesamurai/node-batch/issues"},"homepage":"https://github.com/noblesamurai/node-batch","gitHead":"e100202dccb3f740e416b39bf4a684deda11f424","_id":"work-batcher@2.0.1","_shasum":"27b4af172bde884c4714722525672efd5df88b69","_from":".","_npmVersion":"1.4.13","_npmUser":{"name":"timlesallen","email":"allen.timothy.email@gmail.com"},"maintainers":[{"name":"timlesallen","email":"allen.timothy.email@gmail.com"}],"dist":{"shasum":"27b4af172bde884c4714722525672efd5df88b69","tarball":"https://registry.npmjs.org/work-batcher/-/work-batcher-2.0.1.tgz","integrity":"sha512-TMcx1UlTA7BnZnVo7f9GbyNfa+YIB0Loi8w9QXIXG4Mgg9C6dic3xGR5XcgSnDakXsM5XaYlND+qaV3HKlRDGw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCIYbvOiABP0bM+Vb6HwV9mC8wUdOjY1+uARMDjv18Y4wIgerQ8GGETAmnSCnwgfDHG1lIA+WXUnQqOoeNo8tk9gac="}]}},"2.0.2":{"name":"work-batcher","version":"2.0.2","description":"node-batch ==========","keywords":["batch","multiplex"],"main":"index.js","directories":{"test":"test"},"dependencies":{"async":"^0.9.0","lodash":"^2.4.1"},"devDependencies":{"expect.js":"^0.3.1"},"scripts":{"test":"mocha --recursive test"},"repository":{"type":"git","url":"https://github.com/noblesamurai/node-batch.git"},"author":{"name":"Timothy Leslie Allen","email":"allen.timothy.email@gmail.com","url":"https://github.com/timlesallen"},"license":"ISC","bugs":{"url":"https://github.com/noblesamurai/node-batch/issues"},"homepage":"https://github.com/noblesamurai/node-batch","gitHead":"e100202dccb3f740e416b39bf4a684deda11f424","_id":"work-batcher@2.0.2","_shasum":"8ab40338d7e41ee55b1d98219addb429389d159e","_from":".","_npmVersion":"1.4.13","_npmUser":{"name":"timlesallen","email":"allen.timothy.email@gmail.com"},"maintainers":[{"name":"timlesallen","email":"allen.timothy.email@gmail.com"}],"dist":{"shasum":"8ab40338d7e41ee55b1d98219addb429389d159e","tarball":"https://registry.npmjs.org/work-batcher/-/work-batcher-2.0.2.tgz","integrity":"sha512-rov1BXuq/YoiE7EddIk/CkQc7mK8L5o5hkwPHdkbLHDGFu1puQw3r4d1Ri57PEF+rz+kYGZDntc/qzFhS2z12Q==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCAMLVZW4DBeHM08zmzhOxFk4T0vrgN74K857rK91F50QIhAOZbEHPG7ft7OlTLEW2ZoxRBcPsUmFfqVF6x4usoZJQK"}]}},"3.0.0":{"name":"work-batcher","version":"3.0.0","description":"Aggregates payloads/work parcels together so they can be handled in one go. E.g. use to make one request to an API where payload can be stuffed with multiple items.","keywords":["batch","multiplex"],"main":"index.js","directories":{"test":"test"},"dependencies":{"async":"^0.9.0","lodash":"^2.4.1"},"devDependencies":{"expect.js":"^0.3.1"},"scripts":{"test":"mocha --recursive test"},"repository":{"type":"git","url":"https://github.com/noblesamurai/node-batch.git"},"author":{"name":"Timothy Leslie Allen","email":"allen.timothy.email@gmail.com","url":"https://github.com/timlesallen"},"license":"ISC","bugs":{"url":"https://github.com/noblesamurai/node-batch/issues"},"homepage":"https://github.com/noblesamurai/node-batch","gitHead":"18bec0197b8d330be49349efb645ff36f834cd62","_id":"work-batcher@3.0.0","_shasum":"ca69bf5ac8ba3b4f7cdd223b31e8b20502696998","_from":".","_npmVersion":"1.4.13","_npmUser":{"name":"timlesallen","email":"allen.timothy.email@gmail.com"},"maintainers":[{"name":"timlesallen","email":"allen.timothy.email@gmail.com"}],"dist":{"shasum":"ca69bf5ac8ba3b4f7cdd223b31e8b20502696998","tarball":"https://registry.npmjs.org/work-batcher/-/work-batcher-3.0.0.tgz","npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh3BiTCRA9TVsSAnZWagAAKz0P/jLtRmg0EHw6maNY3hMX\ncIQGZpNSsZY4/Zdh/tDaYIIYzaAZkxC5r0R7SUELBrNiCTFaPxz/YHCt+m+q\nt7U0nMUuHoeLNTlbMBh5Logcp9xwysaY5WGAbqmP6pN+IfZfti9q1OePRQx/\nrCl3SQFt5tY3JwAztUHSchVmj8QlDk2d1+zOZ0W7YNpUa4nD14HWe9apm/z9\n972oBFHjsJaBucKJXYSOI7XITabBjPH30KxgbnkxuslOlgu7jAxqSLIeGzwj\n3K4dgIdccVqv02sBmvWeLH/iBaXnaXlYOFmyjCYSDuE0tzumnj0+61N4BdLr\nB5gRZG9sQcXjonFVUD+o8M6PhlRdmwEMMrHCkX7xgcKdxJMXBpF3U6H5Xn0C\nOD9PPw0ZGLs06NaNCM/9hSyBtetsBYK79rZD67cHFkrgs3p5S+6WzBsTuy4j\nt+9XoQCT0Vnxr34wdgmDuxW4o1qTUdmyDIqFRrmZRxcZb48u3szbJFJFbnv+\nZj/0pBnhzvfs7ABCDrnodZx0AJRj+Hb+8vxPhD6+xeY19AU2hqZHwe4o+TEI\nytU1H+5ejuw91EEXUiP16dIJ9nICwTpI5v7L6/ga/QhOzEKQdec7Y++MnCeS\no6X8UywBT73+9QYCWMLxlhRc6LbLku571e63MzvKZOveoA2rHhJ+A6nPcHE7\nGqqo\r\n=tNW3\r\n-----END PGP SIGNATURE-----\r\n","integrity":"sha512-6perrBQ8vEDMErZKNn1yI52wTLRhK6OtZWHW1u15XBWGY19Zg5+IOJJvpjPPnaCu40zgb8LxH7WrJCnzWRIplw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGMabGNgJNqSP+zK4jKxVpY9/c8+4xNSjbQ7XxekzVEGAiByklparrbzne/EHI0g7itxYFCZmQyOQrRo/zYj5XF3VA=="}]}}},"readme":"work-batcher\n\nModule to handle batching/aggregation of work with a timeout. E.g. batching\nrequests to an API where you can stuff the payload will multiple queries.\n\nYou need to provide a worker.  When either the timeout expires or we have\nenough items, the worker will be called. A function to multiplex the results\ntogether for the worker should be provided, as well as a function to\ndemultiplex the results in the response.\n\n# Usage\n```javascript\n\nvar Batch = require('work-batcher'),\n    async = require('async'),\n    expect = require('expect.js');\n\nvar batch = new Batch({\n  // Will assemble the individual payloads into one payload for the worker when\n  //  it is time to call it.\n  multiplexer: function(items) {\n    return items.join(',');\n  },\n  // Will dis-assemble the result into individual results when the worker gives\n  // us a result.\n  demultiplexer: function(item, index, result) {\n    return result[index];\n  },\n  // The worker to call.  called when we have maxItems or timeout occurs.\n  worker: function(data, callback) {\n    var result = {};\n    data.split(',').forEach(function(item, index) {\n      result[index] = item * item;\n    });\n    callback(null, result);\n  },\n  maxItems: 3,\n  timeout: 500\n});\n\n/**\n * Simple example involving a worker function that returns the squares of each\n * element in the array.\n */\nasync.map([1,2,3,4], function(item, callback) {\n  pool.handleItem(item, callback);\n},\nfunction callback(err, results) {\n  if(err) return done(err);\n\n  expect(results).to.eql([1,4,9,16]);\n  done();\n});\n```\n","maintainers":[{"email":"npm@noblesamurai.com","name":"noblesamurai"},{"email":"eugene@noblesamurai.com","name":"eugeneware"},{"email":"jacob@noblesamurai.com","name":"jacob-samurai"},{"email":"allen.timothy.email@gmail.com","name":"timlesallen"}],"time":{"modified":"2022-06-29T03:17:12.719Z","created":"2014-07-21T04:05:50.145Z","0.0.0":"2014-07-21T04:05:50.145Z","0.0.1":"2014-07-21T04:08:00.286Z","1.0.0":"2014-07-21T04:13:49.280Z","1.0.1":"2014-07-21T04:15:39.158Z","2.0.0":"2014-07-21T05:46:38.220Z","2.0.1":"2014-07-21T05:48:02.825Z","2.0.2":"2014-07-22T00:00:49.077Z","3.0.0":"2014-07-22T03:31:09.038Z"},"homepage":"https://github.com/noblesamurai/node-batch","repository":{"type":"git","url":"https://github.com/noblesamurai/node-batch.git"},"author":{"name":"Timothy Leslie Allen","email":"allen.timothy.email@gmail.com","url":"https://github.com/timlesallen"},"bugs":{"url":"https://github.com/noblesamurai/node-batch/issues"},"license":"ISC","readmeFilename":"README.md","keywords":["batch","multiplex"]}