https://github.com/dzek69/oop-timers
More OOP JavaScript timers.
https://github.com/dzek69/oop-timers
browser ecmascript6 es6 javascript js node oop setinterval settimeout timers
Last synced: 21 days ago
JSON representation
More OOP JavaScript timers.
- Host: GitHub
- URL: https://github.com/dzek69/oop-timers
- Owner: dzek69
- License: mit
- Created: 2018-05-24T21:15:19.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2025-01-09T18:01:05.000Z (about 1 year ago)
- Last Synced: 2025-10-11T12:08:08.515Z (5 months ago)
- Topics: browser, ecmascript6, es6, javascript, js, node, oop, setinterval, settimeout, timers
- Language: TypeScript
- Size: 558 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# oop-timers
This library wraps JavaScript timers (timeout and interval) in a class to provide OOP way of using them.
- 🌟 Extra features - stop repeating yourself
- 🛠 First class TypeScript support - 100% type safe and intellisense friendly
- 📦 No dependencies - it's small and can be used anywhere
- 🌎 Universal - exposes both ESM modules and CommonJS
- 🛡️ Safe - fully tested and used in production
## Quick example
```typescript
import { Timeout } from 'oop-timers';
const timeout = new Timeout(() => console.log('Hello world!'), 1000);
timeout.start();
// Imagine UI with start and stop buttons and input for new timeout value :)
stopButton.addEventListener('click', () => timeout.stop());
startButton.addEventListener('click', () => timeout.start(Number(newTimeoutInput.value)));
```
## Docs
Documentation can be found here: [oop-timers documentation](https://ezez.dev/docs/oop-timers/latest).
## To do
- Support for requestAnimationFrame?
## License
MIT