https://github.com/dafrok/timer-pool
https://github.com/dafrok/timer-pool
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/dafrok/timer-pool
- Owner: Dafrok
- License: mit
- Created: 2021-03-11T09:19:26.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2021-03-11T10:18:46.000Z (over 5 years ago)
- Last Synced: 2025-09-11T19:09:34.455Z (11 months ago)
- Language: JavaScript
- Size: 5.86 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Timer Pool
Timer group management.
## Install
```
$ npm i timer-pool
```
## Usage
```js
import {setTimer, clearTimer, setLoopTimer, clearLoopTimer} from 'timer-pool';
// set timeout in timeout group "foo"
setTimer('foo', () => {
// do something;
});
// set another timeout in timeout group "foo"
setTimer('foo', () => {
// do something else;
});
// set interval in interval group "foo"
setLoopTimer('foo', () => {
// do something;
});
// set timeout in timeout group "bar" and get timeout identifier
const timerId = setTimer('bar', () => {
// do something;
});
// clear timeout by group name
clearTimer('foo');
// clear timeout by identifier
clearTimer(timerId);
// clear interval by group name
clearLoopTimer('foo');
```