{"name":"retimer","version":"2.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":"^12.0.0","tape":"^4.0.0"},"browser":{"./time.js":"./time-browser.js"},"gitHead":"7b90aa31e740745e10a6a90bf09b738b56f42594","_id":"retimer@2.0.0","_npmVersion":"6.4.1","_nodeVersion":"11.3.0","_npmUser":{"name":"matteo.collina","email":"hello@matteocollina.com"},"dist":{"integrity":"sha512-KLXY85WkEq2V2bKex/LOO1ViXVn2KGYe4PYysAdYdjmraYIUsVkXu8O4am+8+5UbaaGl1qho4aqAAPHNQ4GSbg==","shasum":"e8bd68c5e5a8ec2f49ccb5c636db84c04063bbca","tarball":"http://registry-npm.ywwl.com/retimer/download/retimer-2.0.0.tgz","fileCount":9,"unpackedSize":7898,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcEqSDCRA9TVsSAnZWagAAVd8P/jDqkMp28KRwiZxy9wNf\nsv93evY8f9fnBb+xytWfXlWQEiZTB9EaS2gDw7LYs32m/xDzLj9fM/68pQjA\nDJIOftc/twtnkCROIaGCWqUXjpjpJOtY5xGfpa3wklF8pcpmLFkHgjL/4FC0\nZCaaIL/3JLDc1oE3msHIDjAiQSY1PgvMEmWNXpylmPIawhY4qSJDJUthpbrQ\nsGCW1RNAEZBBuu5m6S5ekKjrmXtNUem/llS1hbhdORrZ48Xy5La27yOwZtQD\nlaE5Q2CQmdBz9Ra9u43U2ZxpZ71ch5BnSSjPJWOhFKhUzYNup5EkOUvnQVDR\nm0k+rfLT3xsEWzmroZP3uygYzVoXB9dYJPMT0lgvZgVPDDpRYuswPJu+mgcH\neAufIBN+03WqH0NmvK1dgC+29Na4MK/rHiiLtbTBpBGLnSVCEWA7Ucjr7Ok8\n3GlhL0d42Lg/arq20wOYWwDMM7grMJya0a8bRq0/RlZi86sfq/X+VMAq9by1\nceB5H7BJTbbjqrmQuK8cejCNAcPWpCCh3xxhNG3M73UqbaU2SHZocQjRAGjf\nzxGoMn3zU3dQT1NoQXFHb/GE4Golp/7JXQQBBPqxDP+PvIxKox86N4sUCog0\nVLGhhYAuouuBX46l50oadkZ69uZModP+vjhSxAI6TbFN0NcGPQpHWVheEzBx\nERqk\r\n=GxaG\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQChZtcJ438jPsbfqxRpme/B9Y/NyPDGnt/B82qdO75RHAIgHxZxTAac8i1tDukr8oQO9rK3vA1FZLUkYaFXox4dLBs="}],"size":3091,"noattachment":false,"key":"/retimer/-/retimer-2.0.0.tgz"},"maintainers":[{"name":"matteo.collina","email":"hello@matteocollina.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/retimer_2.0.0_1544725634755_0.8922109887785181"},"_hasShrinkwrap":false,"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":1544725634919,"_cnpm_publish_time":1544725634919,"dist-tags":{"latest":"4.0.0"}}