{"name":"retimer","version":"3.0.0","description":"Reschedulable Timer for your node needs","main":"retimer.js","scripts":{"lint":"standard","test":"tape test.js | tap-dot"},"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","pre-commit":"^1.0.10","standard":"^16.0.0","tap-dot":"^2.0.0","tape":"^5.0.0"},"browser":{"./time.js":"./time-browser.js"},"gitHead":"fd4dc9721bfca72754fbc7c5e0f2f2d630edfa72","_id":"retimer@3.0.0","_nodeVersion":"14.15.4","_npmVersion":"6.14.11","_npmUser":{"name":"matteo.collina","email":"hello@matteocollina.com"},"dist":{"integrity":"sha512-WKE0j11Pa0ZJI5YIk0nflGI7SQsfl2ljihVy7ogh7DeQSeYAUi0ubZ/yEueGtDfUPk6GH5LRw1hBdLq4IwUBWA==","shasum":"98b751b1feaf1af13eb0228f8ea68b8f9da530df","tarball":"http://registry-npm.ywwl.com/retimer/download/retimer-3.0.0.tgz","fileCount":9,"unpackedSize":8877,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgPhxTCRA9TVsSAnZWagAAXIcP/AoNE1JgTN74w1a393yC\nJMgIMZe9ZBFq409wWYMsS3H21eKSp0NKCwNNzOWcdSUnAKbvE8I8wGZfFoVB\nPVpJBUZDOYjOhymgugTkpkxNK3I+GINTSOzfmG8FgAOvWP9u1njc5B+qAieN\n+hnzYybXskHu57KPcID3RtMldFZBNoZn52CyCo3jvpLaWMMKKrBGBvgUEhOK\nY5JQOX1OwjpZaEaNpt/q2NiwEvN1Ja+ylay03+He45mRfEl9G7PGvYFD35n/\nMGHNaAJhMWHe0u3m0W0d5dJdcB08DnFyXncYPBkZAEdHhlFM8SxRmYy4yFAo\negR6YXjyFtny7sNqjON1PmhlyGuC7rZKIP1hCz0vtq6qWK6W3IXxojSGNh3N\nQF8Y66T+ocr5K+pETb/rv7B7bRdRPcYS+9BdPsU4Dki38y0d/6fVlsWE/IOH\nt9JcvpDzLLyJICA6/wFU+uIuotB7J+FpH5PqhlxpGwWgIbVutdOIkP3wyrZM\nBhgj9SSq5JCEubMfMbmFBRDVrdJ3kEKdB2fNjiQ6LE+gwttvoEsieuLUg/z+\n3cmbHlzomxaGIoam93CESoRp2aGqKhUFtOePw200aBJ0qwnUN0LKluk1aSqs\nSUcOsDzP+NX0W/OTWR2+jAaUnc1vpIxQmCH4hP64XvKeN+kb0GtRHKnkx5h8\nacbM\r\n=MNzO\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD4Qns3GeEVDZSOeiVUSqPKMiG5CU7/HdNYm4O8ZLh5NwIgf//6Ml9cVp3f4GLcT3HBbjTZ/2c9Dx0USgjkLzCshd8="}],"size":3311,"noattachment":false,"key":"/retimer/-/retimer-3.0.0.tgz"},"directories":{},"maintainers":[{"name":"matteo.collina","email":"hello@matteocollina.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/retimer_3.0.0_1614683218944_0.8560379593629281"},"_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":1614683219109,"_cnpm_publish_time":1614683219109,"dist-tags":{"latest":"4.0.0"}}