{"name":"retimer","version":"0.0.1","description":"Reschedulable Timer for your node needs","main":"retimer.js","scripts":{"test":"tape test.js | faucet"},"repository":{"type":"git","url":"git+https://github.com/mcollina/retimer.git"},"keywords":["schedulable","reschedulable","timer","setTimeout"],"author":{"name":"Matteo Collina","email":"hello@matteocollina.com"},"license":"MIT","bugs":{"url":"https://github.com/mcollina/retimer/issues"},"homepage":"https://github.com/mcollina/retimer#readme","gitHead":"8269f0eec6f485408953a7125ad1b7aa821d6e6f","_id":"retimer@0.0.1","_shasum":"8d0494e5b85f1ed9ccfcbbd80f8d26c8180c1b93","_from":".","_npmVersion":"2.11.3","_nodeVersion":"2.3.1","_npmUser":{"name":"matteo.collina","email":"hello@matteocollina.com"},"maintainers":[{"name":"matteo.collina","email":"hello@matteocollina.com"}],"dist":{"shasum":"8d0494e5b85f1ed9ccfcbbd80f8d26c8180c1b93","tarball":"http://registry-npm.ywwl.com/retimer/download/retimer-0.0.1.tgz","integrity":"sha512-jpRPtoViRgSC3lig50ngOtVVnwmUKTz2N5HXbF8dWfVyZ7p3i9q8KRzUX4m+Z7nowK8TYnphQUwnMfbKBMia6Q==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGItnsAaKXFPNdJsN6mLkikfeycekVx/FVzy8NBRK/1kAiEA2qsH4yPTCP9dMiybUb7MvM0j7ufi7yYp0OigFqIpHiQ="}],"size":1452,"noattachment":false,"key":"/retimer/-/retimer-0.0.1.tgz"},"directories":{},"readme":"# retimer&nbsp;&nbsp;[![Build Status](https://travis-ci.org/mcollina/retimer.png)](https://travis-ci.org/mcollina/retimer)\n\nreschedulable setTimeout for your node needs. This library is built for\nbuilding a keep alive functionality across a large numbers of\nclients/sockets.\n\nRescheduling a 10000 functions 20 times with an interval of 50ms (see\n`bench.js`), with 100 repetitions:\n\n* `benchSetTimeout*100: 40.295s`\n* `benchRetimer*100: 36.122s`\n\n\n## Install\n\n```\nnpm install retimer --save\n```\n\n## Example\n\n```js\nvar retimer = require('retimer')\nvar timer = retimer(function () {\n  throw new Error('this should never get called!')\n}, 20)\n\nsetTimeout(function () {\n  timer.reschedule(50)\n  setTimeout(function () {\n    timer.clear()\n  }, 10)\n}, 10)\n```\n\n## API\n\n### retimer(callback, timeout, [...args])\n\nExactly like your beloved `setTimeout`.\nReturns a `Retimer object`\n\n### timer.reschedule(timeout)\n\nReschedule the timer.\nRetimer will not gove any performance benefit if the specified timeout comes __before__ the original timeout.\n\n### timer.clear()\n\nClear the timer, like your beloved `clearTimeout`.\n\n## How it works\n\nTimers are stored in a Linked List in node.js, if you create a lot of\ntimers this Linked List becomes massive which makes __removing a timer an expensive operation__.\nRetimer let the old timer run at its time, and schedule a new one accordingly, when the new one is __after__ the original timeout.\nThere is no performance gain when the new timeout is before the original one as retimer will just __remove the previous timer__.\n\n## License\n\nMIT\n","publish_time":1436373677770,"_cnpm_publish_time":1436373677770,"dist-tags":{"latest":"4.0.0"}}