{"_id":"atomic-batcher","_rev":"480874","name":"atomic-batcher","description":"A simple batching function that allows you to atomically batch a series of operations.","dist-tags":{"latest":"1.0.2"},"maintainers":[{"name":"mafintosh","email":""}],"time":{"modified":"2021-08-05T09:35:46.000Z","created":"2016-07-11T14:20:58.040Z","1.0.2":"2017-02-12T22:58:12.925Z","1.0.1":"2017-01-26T03:12:47.731Z","1.0.0":"2016-07-11T14:20:58.040Z"},"users":{},"author":{"name":"Mathias Buus","url":"@mafintosh"},"repository":{"type":"git","url":"git+https://github.com/mafintosh/atomic-batcher.git"},"versions":{"1.0.2":{"name":"atomic-batcher","version":"1.0.2","description":"A simple batching function that allows you to atomically batch a series of operations.","main":"index.js","dependencies":{},"devDependencies":{"standard":"^7.1.2","tape":"^4.6.0"},"scripts":{"test":"standard && tape test.js"},"repository":{"type":"git","url":"git+https://github.com/mafintosh/atomic-batcher.git"},"author":{"name":"Mathias Buus","url":"@mafintosh"},"license":"MIT","bugs":{"url":"https://github.com/mafintosh/atomic-batcher/issues"},"homepage":"https://github.com/mafintosh/atomic-batcher","gitHead":"892a4a6c153f209b5b664df351c7c2bd15653d57","_id":"atomic-batcher@1.0.2","_shasum":"d16901d10ccec59516c197b9ccd8930689b813b4","_from":".","_npmVersion":"3.10.10","_nodeVersion":"6.9.5","_npmUser":{"name":"mafintosh","email":"mathiasbuus@gmail.com"},"dist":{"shasum":"d16901d10ccec59516c197b9ccd8930689b813b4","size":2632,"noattachment":false,"key":"/atomic-batcher/-/atomic-batcher-1.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/atomic-batcher/download/atomic-batcher-1.0.2.tgz"},"maintainers":[{"name":"mafintosh","email":""}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/atomic-batcher-1.0.2.tgz_1486940291022_0.9458728104364127"},"directories":{},"publish_time":1486940292925,"_cnpm_publish_time":1486940292925,"_hasShrinkwrap":false},"1.0.1":{"name":"atomic-batcher","version":"1.0.1","description":"A simple batching function that allows you to atomically batch a series of operations.","main":"index.js","dependencies":{},"devDependencies":{"standard":"^7.1.2","tape":"^4.6.0"},"scripts":{"test":"standard && tape test.js"},"repository":{"type":"git","url":"git+https://github.com/mafintosh/atomic-batcher.git"},"author":{"name":"Mathias Buus","url":"@mafintosh"},"license":"MIT","bugs":{"url":"https://github.com/mafintosh/atomic-batcher/issues"},"homepage":"https://github.com/mafintosh/atomic-batcher","gitHead":"71f8a7c6f5a6f699a575358b37023435c9dbc06b","_id":"atomic-batcher@1.0.1","_shasum":"8191d98593ef49be3cb44a973c10cb47ff2be6e7","_from":".","_npmVersion":"2.15.11","_nodeVersion":"4.7.2","_npmUser":{"name":"mafintosh","email":"mathiasbuus@gmail.com"},"dist":{"shasum":"8191d98593ef49be3cb44a973c10cb47ff2be6e7","size":2582,"noattachment":false,"key":"/atomic-batcher/-/atomic-batcher-1.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/atomic-batcher/download/atomic-batcher-1.0.1.tgz"},"maintainers":[{"name":"mafintosh","email":""}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/atomic-batcher-1.0.1.tgz_1485400365945_0.7426749705336988"},"directories":{},"publish_time":1485400367731,"_cnpm_publish_time":1485400367731,"_hasShrinkwrap":false},"1.0.0":{"name":"atomic-batcher","version":"1.0.0","description":"A simple batching function that allows you to atomically batch a series of operations.","main":"index.js","dependencies":{},"devDependencies":{"standard":"^7.1.2","tape":"^4.6.0"},"scripts":{"test":"standard && tape test.js"},"repository":{"type":"git","url":"git+https://github.com/mafintosh/atomic-batcher.git"},"author":{"name":"Mathias Buus","url":"@mafintosh"},"license":"MIT","bugs":{"url":"https://github.com/mafintosh/atomic-batcher/issues"},"homepage":"https://github.com/mafintosh/atomic-batcher","gitHead":"f6c19bcae39ae34bce3c4d501544a4f0af48b9ce","_id":"atomic-batcher@1.0.0","_shasum":"0b9a44ead5d6e84709961b988d4a382c521c45fe","_from":".","_npmVersion":"2.15.9","_nodeVersion":"4.4.3","_npmUser":{"name":"mafintosh","email":"mathiasbuus@gmail.com"},"dist":{"shasum":"0b9a44ead5d6e84709961b988d4a382c521c45fe","size":2474,"noattachment":false,"key":"/atomic-batcher/-/atomic-batcher-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/atomic-batcher/download/atomic-batcher-1.0.0.tgz"},"maintainers":[{"name":"mafintosh","email":""}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/atomic-batcher-1.0.0.tgz_1468246855657_0.3219797450583428"},"directories":{},"publish_time":1468246858040,"_cnpm_publish_time":1468246858040,"_hasShrinkwrap":false}},"readme":"# atomic-batcher\n\nA simple batching function that allows you to atomically batch a series of operations. If you are looking for the same thing with a stream interface checkout [byte-stream](https://github.com/maxogden/byte-stream).\n\n```\nnpm install atomic-batcher\n```\n\n[![build status](http://img.shields.io/travis/mafintosh/atomic-batcher.svg?style=flat)](http://travis-ci.org/mafintosh/atomic-batcher)\n\n## Usage\n\n``` js\nvar batcher = require('atomic-batcher')\nvar db = require('level')('some.db')\n\nvar batch = batcher(function work (ops, cb) {\n  // only one batch will happen at the time\n  console.log('Batching:', ops, '\\n')\n  db.batch(ops, cb)\n})\n\nbatch({type: 'put', key: 'hello', value: 'world-1'})\nbatch({type: 'put', key: 'hello', value: 'world-2'})\nbatch({type: 'put', key: 'hello', value: 'world-3'})\nbatch({type: 'put', key: 'hi', value: 'hello'}, function () {\n  console.log('Printing latest values:\\n')\n  db.get('hello', console.log) // returns world-3\n  db.get('hi', console.log) // returns hello\n})\n```\n\nRunning the above example will print\n\n```\nBatching: [ { type: 'put', key: 'hello', value: 'world-1' } ]\n\nBatching: [ { type: 'put', key: 'hello', value: 'world-2' },\n  { type: 'put', key: 'hello', value: 'world-3' },\n  { type: 'put', key: 'hi', value: 'hello' } ]\n\nPrinting latest values:\n\nnull 'world-3'\nnull 'hello'\n```\n\n## API\n\n#### `var batch = batcher(worker)`\n\nCreate a new batching function. `worker` should be a function that accepts a batch and a callback, `(batch, cb)`.\nOnly one batch is guaranteed to be run at the time.\n\nThe `batch` function accepts a value or an array of values and a callback, `batch(value(s), cb)`. The callback is called when the batch containing the values have been run.\n\n## License\n\nMIT\n","_attachments":{},"homepage":"https://github.com/mafintosh/atomic-batcher","bugs":{"url":"https://github.com/mafintosh/atomic-batcher/issues"},"license":"MIT"}