Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cfware/cleanable-interval
A variant of setInterval that returns a cleanup function.
https://github.com/cfware/cleanable-interval
Last synced: 29 days ago
JSON representation
A variant of setInterval that returns a cleanup function.
- Host: GitHub
- URL: https://github.com/cfware/cleanable-interval
- Owner: cfware
- License: mit
- Created: 2019-03-23T04:23:05.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2023-10-15T15:24:57.000Z (about 1 year ago)
- Last Synced: 2024-11-07T23:29:31.849Z (about 2 months ago)
- Language: JavaScript
- Size: 28.3 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# @cfware/cleanable-interval [![NPM Version][npm-image]][npm-url]
A variant of setInterval that returns a cleanup function.
## Usage
```js
import cleanableInterval from '@cfware/cleanable-interval';let iter = 0;
const cleanupFn = cleanableInterval(() => {
iter++;
console.log(`Iteration ${iter} of 2`);
if (iter > 1) {
cleanupFn();
}
}, 100);
```[npm-image]: https://img.shields.io/npm/v/@cfware/cleanable-interval.svg
[npm-url]: https://npmjs.org/package/@cfware/cleanable-interval