https://github.com/streamich/set-harmonic-interval
one timer for all setInterval() with identical ms delay
https://github.com/streamich/set-harmonic-interval
Last synced: 11 months ago
JSON representation
one timer for all setInterval() with identical ms delay
- Host: GitHub
- URL: https://github.com/streamich/set-harmonic-interval
- Owner: streamich
- License: unlicense
- Created: 2019-08-25T00:24:55.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2023-12-15T11:56:59.000Z (over 2 years ago)
- Last Synced: 2025-08-09T15:51:51.887Z (11 months ago)
- Language: TypeScript
- Size: 1.66 MB
- Stars: 12
- Watchers: 3
- Forks: 1
- Open Issues: 22
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# set-harmonic-interval
Works similar to `setInterval`, but calls all callbacks scheduled using `setHarmonicInterval` all at once, which have same
delay in milliseconds.
## Install
```
npm install set-harmonic-interval
```
## Usage
In below example `1` and `2` will always be printed together every second.
```js
const { setHarmonicInterval, clearHarmonicInterval } = require('set-harmonic-interval');
setHarmonicInterval(() => console.log(1), 1000);
setTimeout(() => {
setHarmonicInterval(() => console.log(2), 1000);
}, 500);
```
## License
[Unlicense](LICENSE) — public domain.