{"name":"retimer","version":"1.1.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":"^10.0.0","tape":"^4.0.0"},"gitHead":"31ea94f195780b7b65ec573aff8dd104062e02e1","_id":"retimer@1.1.0","_npmVersion":"5.4.2","_nodeVersion":"8.6.0","_npmUser":{"name":"matteo.collina","email":"hello@matteocollina.com"},"dist":{"integrity":"sha512-+Tjoa47XqpO+cmNObvmK6UPFmUTzQPtr4MqMS7ZJKPKYAnryCxG2FXT8/SEgPsEghQQgXFPZEdILNxJkvXtjUw==","shasum":"8cb2cec5cc200c245622e943aa11549f25c5ed2c","tarball":"http://registry-npm.ywwl.com/retimer/download/retimer-1.1.0.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDwT0mY8C9RGOFdnWcXqLzvhAkr4za7UqhmXnI6a2e0UAIgdeB70GOyQhhV28nBAq8jKesLgZxWxYk9ac5O0W+Y4Jw="}],"size":2995,"noattachment":false,"key":"/retimer/-/retimer-1.1.0.tgz"},"maintainers":[{"name":"matteo.collina","email":"hello@matteocollina.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/retimer-1.1.0.tgz_1507536978354_0.09810336516238749"},"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":1507536979320,"_cnpm_publish_time":1507536979320,"dist-tags":{"latest":"4.0.0"}}