Comparing version 0.0.1 to 1.0.0
{ | ||
"name": "retimer", | ||
"version": "0.0.1", | ||
"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": { | ||
@@ -24,3 +29,10 @@ "type": "git", | ||
}, | ||
"homepage": "https://github.com/mcollina/retimer#readme" | ||
"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" | ||
} | ||
} |
# retimer | ||
reschedulable setTimeout for you node needs | ||
reschedulable setTimeout for you node needs. This library is built for | ||
building a keep alive functionality across a large numbers of | ||
clients/sockets. | ||
Rescheduling a 10000 functions 20 times with an interval of 50ms (see | ||
`bench.js`), with 100 repetitions: | ||
* `benchSetTimeout*100`: 51867ms | ||
* `benchRetimer*100`: 34237ms | ||
## Install | ||
``` | ||
npm install retimer --save | ||
``` | ||
## Example | ||
```js | ||
var retimer = require('retimer') | ||
var timer = retimer(function () { | ||
throw new Error('this should never get called!') | ||
}, 20) | ||
setTimeout(function () { | ||
timer.reschedule(50) | ||
setTimeout(function () { | ||
timer.clear() | ||
}, 10) | ||
}, 10) | ||
``` | ||
## API | ||
### retimer(callback, timeout, [...args]) | ||
Exactly like your beloved `setTimeout`. | ||
Returns a `Retimer object` | ||
### timer.reschedule(timeout) | ||
Reschedule the timer, if the specified timeout comes __after__ the | ||
original timeout. | ||
Returns true if successful, false otherwise | ||
### timer.clear() | ||
Clear the timer, like your beloved `clearTimeout`. | ||
## How it works | ||
Timers are stored in a Linked List in node.js, if you create a lot of | ||
timers this Linked List becomes massive which makes __removing a timer an expensive operation__. | ||
Retimer let the old timer run at its time, and schedule a new one accordingly. | ||
## License | ||
MIT |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Empty package
Supply chain riskPackage does not contain any code. It may be removed, is name squatting, or the result of a faulty package publish.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
7938
7
173
0
62
0
5