{"name":"last-one-wins","version":"1.0.2","description":"Make sure the last sync call to an async function is executed after all previous ones have finished","main":"index.js","dependencies":{},"devDependencies":{"standard":"^5.4.1","tape":"^4.2.2"},"scripts":{"test":"standard && tape test.js"},"repository":{"type":"git","url":"https://github.com/mafintosh/last-one-wins.git"},"author":{"name":"Mathias Buus","url":"@mafintosh"},"license":"MIT","bugs":{"url":"https://github.com/mafintosh/last-one-wins/issues"},"homepage":"https://github.com/mafintosh/last-one-wins","gitHead":"7738338b5146df6f709c8495f93391d66d8af997","_id":"last-one-wins@1.0.2","_shasum":"e8d5117db6e072cb919112e648d2cf843454780c","_from":".","_npmVersion":"2.14.7","_nodeVersion":"4.2.3","_npmUser":{"name":"mafintosh","email":"mathiasbuus@gmail.com"},"dist":{"shasum":"e8d5117db6e072cb919112e648d2cf843454780c","tarball":"http://registry-npm.ywwl.com/last-one-wins/download/last-one-wins-1.0.2.tgz","integrity":"sha512-ETyNR9KqBFV/iK3CTJV+RXwikVP1x9jHhJfn47OkqtiQpL8tsryyaqih9IWRQBKrrM+P01DnSJyohDGMF6q5wA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFcnNXMK4LcBNupe/GvaC/OFR4ETgpCs6v8ZzJrRK0AoAiBpLyuBEhEkjtjmrbYwy6CiomL/otqDUnBEacWHRxNRKQ=="}],"size":2529,"noattachment":false,"key":"/last-one-wins/-/last-one-wins-1.0.2.tgz"},"maintainers":[{"name":"mafintosh","email":"mathiasbuus@gmail.com"}],"directories":{},"readme":"# last-one-wins\n\nMake sure the last sync call to an async function is executed after all previous ones have finished\n\n```\nnpm install last-one-wins\n```\n\n[![build status](http://img.shields.io/travis/mafintosh/last-one-wins.svg?style=flat)](http://travis-ci.org/mafintosh/last-one-wins)\n\n## Usage\n\n``` js\nvar low = require('last-one-wins')\n\nvar pick = low(function (num, cb) {\n  setTimeout(function () {\n    console.log('picked', num)\n    cb()\n  }, Math.floor(Math.random() * 100))\n})\n\npick(1)\npick(2)\npick(3)\npick(4)\npick(5) // this one will always win since its called the last\n```\n\nCalling the above will print out\n\n```\npicked 1\npicked 5\n```\n\n## API\n\n#### `var fn = low(asyncWorker)`\n\nWrap a async function to make sure that the last sync call to that\nfunction is executed after any previous calls. Note that not all calls\nare executed - only the last one is guaranteed to be executed.\n\n`fn` and `asyncWorker` should have the signature `(value, cb)`\n\n## Use with leveldb\n\nThis module is useful if you want sync a value to a leveldb and want to\nmake sure the latest version of that value is the one written. For example\n\n``` js\nvar update = low(function (val, cb) {\n  db.put('my-key', val, cb)\n})\n\nupdate('a')\nupdate('b')\nupdate('c')\n```\n\nIs guaranteed to always write `c` to the key `my-key`.\n\n## License\n\nMIT\n","publish_time":1452729315965,"_cnpm_publish_time":1452729315965,"dist-tags":{"latest":"1.0.4"}}