Skip to content

Latest commit

 

History

History
26 lines (21 loc) · 524 Bytes

File metadata and controls

26 lines (21 loc) · 524 Bytes

@jagi/set-interval-time-fn

Example usage

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.