{"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","tarball":"http://registry-npm.ywwl.com/atomic-batcher/download/atomic-batcher-1.0.2.tgz","integrity":"sha512-EFGCRj4kLX1dHv1cDzTk+xbjBFj1GnJDpui52YmEcxxHHEWjYyT6l51U7n6WQ28osZH4S9gSybxe56Vm7vB61Q==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDgsD2kxQ9umo0W2bUKKcEX1mk2jYm64TFn6iSlwrsTKAIgbnXfqgaSYCJEcsOQJ9jnHjJ7YQeKFnLZxFWkg2YE4cY="}],"size":2632,"noattachment":false,"key":"/atomic-batcher/-/atomic-batcher-1.0.2.tgz"},"maintainers":[{"name":"mafintosh","email":"mathiasbuus@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/atomic-batcher-1.0.2.tgz_1486940291022_0.9458728104364127"},"directories":{},"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","publish_time":1486940292925,"_cnpm_publish_time":1486940292925,"dist-tags":{"latest":"1.0.2"}}