https://github.com/jagi/set-interval-time-fn
https://github.com/jagi/set-interval-time-fn
Last synced: over 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/jagi/set-interval-time-fn
- Owner: jagi
- Created: 2018-07-24T16:15:31.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-07-24T16:48:27.000Z (almost 8 years ago)
- Last Synced: 2025-02-25T08:47:07.058Z (over 1 year ago)
- Language: TypeScript
- Size: 3.91 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# @jagi/set-interval-time-fn
## Example usage
```js
import {
setIntervalTimeFn,
clearIntervalTimeFn,
} from "@jagi/set-interval-time-fn";
const start = Date.now();
const timerId = setIntervalTimeFn(
() => {
console.log(`${Date.now() - start} ms elapsed`);
},
time => {
// Start interval from 1 second and increase it by 1 second on each execution.
return !time ? 1000 : time + 1000;
},
);
setTimeout(() => {
clearIntervalTimeFn(timerId);
}, 10 * 1000); // Clear interval after 20 seconds.
```