Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/component/timers
Timer management (setInterval / setTimeout)
https://github.com/component/timers
Last synced: 13 days ago
JSON representation
Timer management (setInterval / setTimeout)
- Host: GitHub
- URL: https://github.com/component/timers
- Owner: component
- Created: 2013-05-21T00:53:39.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2013-05-21T00:54:35.000Z (over 11 years ago)
- Last Synced: 2024-05-08T17:06:41.471Z (8 months ago)
- Language: JavaScript
- Size: 192 KB
- Stars: 12
- Watchers: 7
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
- Changelog: History.md
Awesome Lists containing this project
README
# timers
Timer management to clear large batches of timers.
## Installation
$ component install component/timers
## Example
In the following example the last two timers will not fire.
```js
var Timers = require('timers');
var timers = new Timers;timers.timeout(function(){
console.log('one');
}, 1000);timers.timeout(function(){
console.log('two');
}, 2000);timers.timeout(function(){
console.log('three');
}, 3000);setTimeout(function(){
timers.clear();
}, 1500);
```## API
### Timers()
Initialize a new timer set with optional `ids`.
### Timers.timeout(fn:Function, ms:Number)
Add timeout `fn`.
### Timers.interval(fn:Function, ms:Number)
Add interval `fn`.
### Timers.clear()
Clear all timers.
## License
MIT