{"name":"retimer","version":"4.0.0","description":"Reschedulable Timer for your node needs","main":"retimer.js","types":"types.d.ts","scripts":{"lint":"standard","test":"npm run test:ci && npm run test:typescript","test:ci":"tape test.js | tap-dot","test:typescript":"tsd"},"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.1","pre-commit":"^1.2.2","standard":"^17.1.0","tap-dot":"^2.0.0","tape":"^5.6.6","tsd":"^0.28.1"},"browser":{"./time.js":"./time-browser.js","./timers.js":"./timers-browser.js"},"dependencies":{"worker-timers":"^7.0.75"},"gitHead":"2bdb42dc1547203eafbaaa1cd14f7af9f8995bbf","_id":"retimer@4.0.0","_nodeVersion":"18.16.1","_npmVersion":"9.5.1","dist":{"integrity":"sha512-fZIVtvbOsQsxNSDhpdPOX4lx5Ss2ni+S72AUBitARpFhtA3UzrAjQ6gDtypB2/+l7L+1VQgAgpvAKY66mElH0w==","shasum":"41a8c09710281013ee83ef3a5f8279c02b5a4a8e","tarball":"http://registry-npm.ywwl.com/retimer/download/retimer-4.0.0.tgz","fileCount":13,"unpackedSize":10714,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFFsBzHYRRzYc6qJ4paNSnCY6HofkimG1kx/AoPhWJFnAiA/44UOWm/MiIa5Zzya14dvgLu3+0uAuql9u6mtHWebCw=="}],"size":3948,"noattachment":false,"key":"/retimer/-/retimer-4.0.0.tgz"},"_npmUser":{"name":"matteo.collina","email":"hello@matteocollina.com"},"directories":{},"maintainers":[{"name":"matteo.collina","email":"hello@matteocollina.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/retimer_4.0.0_1691740784824_0.3141443630158989"},"_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":1691740785003,"_cnpm_publish_time":1691740785003,"dist-tags":{"latest":"4.0.0"}}