{"name":"retimer","version":"1.0.0","description":"Reschedulable Timer for your node needs","main":"retimer.js","scripts":{"lint":"standard","test":"tape test.js | faucet"},"pre-commit":["lint","test"],"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","devDependencies":{"fastbench":"^1.0.0","faucet":"0.0.1","pre-commit":"^1.0.10","standard":"^4.5.2","tape":"^4.0.0"},"gitHead":"a2db92736bc0a352e4d9378a12de857159738ee4","_id":"retimer@1.0.0","_shasum":"2a7c6e59619452e44e60267e4ba2564148758694","_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":"2a7c6e59619452e44e60267e4ba2564148758694","tarball":"http://registry-npm.ywwl.com/retimer/download/retimer-1.0.0.tgz","integrity":"sha512-mACS7IAnrKM8RWG2le2xSUUxK5EDuxli5JNlvyD9UgkniAz1TubvR3VtCyfRxqyX7uPc93fmGxpsUVIGA8N6eg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIA6jugJEyg83CJtCg1PIsEURkZgbm4iOsM7Zm3fLtbWLAiEA6KfV1J5+wiytMxS50od3y3XJ16HGeOckbujGz97IIEE="}],"size":3170,"noattachment":false,"key":"/retimer/-/retimer-1.0.0.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":1436603542318,"_cnpm_publish_time":1436603542318,"dist-tags":{"latest":"4.0.0"}}