# @stream-io/worker-timer

A `Worker` based implementation of the JS Timers API.

## Usage

```ts
// import the library
import { WorkerTimer } from "@stream-io/worker-timer";

// create an instance
const timer = new WorkerTimer();

// with interval
const id = timer.setInterval(() => {
  console.log("Hello World from interval");
}, 1000);

// clear the interval
timer.clearInterval(id);

// with timeout
timer.setTimeout(() => {
  console.log("Hello World from timeout");
}, 1000);

// clear the timeout
timer.clearTimeout(id);
```

## Advanced usage

You can also create a `WorkerTimer` instance with custom defaults:

```ts
const timer = new WorkerTimer({
  useWorker: false, // will fallback the Platform API
  name: "custom-timer", // name of the worker, for debugging purposes
});
```
