# worker-timers-broker

> The broker which is used by the worker-timers package.

Latest version **8.0.18** (published 2026-06-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install worker-timers-broker
pnpm add worker-timers-broker
yarn add worker-timers-broker
bun add worker-timers-broker
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 8.0.18 |
| Published | 2026-06-22 |
| First published | 2016-11-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 5 |
| Unpacked size | 34.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 7 |
| Author | Christoph Guttandin |
| Maintainers | chrisguttandin |

## Links

- npm: https://www.npmjs.com/package/worker-timers-broker
- Repository: https://github.com/chrisguttandin/worker-timers-broker
- Issues: https://github.com/chrisguttandin/worker-timers-broker/issues
- npm.io page: https://npm.io/package/worker-timers-broker

## Dependencies (5)

- [tslib](https://npm.io/package/tslib.md) ^2.8.1
- [@babel/runtime](https://npm.io/package/@babel/runtime.md) ^7.29.7
- [broker-factory](https://npm.io/package/broker-factory.md) ^3.1.15
- [fast-unique-numbers](https://npm.io/package/fast-unique-numbers.md) ^9.0.27
- [worker-timers-worker](https://npm.io/package/worker-timers-worker.md) ^9.0.15

## Recent versions

- 8.0.18 (latest) — 2026-06-22
- 8.0.17 — 2026-06-15
- 8.0.16 — 2026-03-17
- 8.0.15 — 2026-01-16
- 8.0.14 — 2026-01-08
- 8.0.13 — 2025-12-20
- 8.0.12 — 2025-12-14
- 8.0.11 — 2025-09-21
- 8.0.10 — 2025-08-16
- 8.0.9 — 2025-07-09
- 8.0.8 — 2025-06-11
- 8.0.7 — 2025-05-13
- 8.0.6 — 2025-03-25
- 8.0.5 — 2025-03-11
- 8.0.4 — 2025-03-06
- … 213 more at https://npm.io/package/worker-timers-broker/versions

## README

# worker-timers-broker

**The broker which is used by the worker-timers package.**

[![version](https://img.shields.io/npm/v/worker-timers-broker.svg?style=flat-square)](https://www.npmjs.com/package/worker-timers-broker)

## Usage

In most cases using this package via [`worker-timers`](https://github.com/chrisguttandin/worker-timers) is probably the most convenient choice.

However `worker-timers-broker` is published as a separate package on npm. It can be installed using the following command:

```shell
npm install worker-timers-broker
```

The package exports two functions.

### load()

The `load()` function can be used to create a custom instance of `worker-timers` by explicitly specifying the URL which points to the code of the [`worker-timers-worker`](https://github.com/chrisguttandin/worker-timers-worker) package.

```js
import { load } from 'worker-timers-broker';

const { clearInterval, clearTimeout, setInterval, setTimeout } = load('./the/worker-timers-worker/file');

const intervalId = setInterval(() => {
    // do something many times
}, 100);

clearInterval(intervalId);

const timeoutId = setTimeout(() => {
    // do something once
}, 100);

clearTimeout(timeoutId);
```

### wrap()

The `wrap()` function can be used to wrap a Web Worker instance which already runs the code of the [`worker-timers-worker`](https://github.com/chrisguttandin/worker-timers-worker) package.

In a project using [Vite](https://vite.dev) it can for example be used by leveraging [query suffixes](https://vite.dev/guide/features.html#import-with-query-suffixes).

```js
import { wrap } from 'worker-timers-broker';
import createWorkerTimersWorker from 'worker-timers-worker?worker';

const { clearInterval, clearTimeout, setInterval, setTimeout } = wrap(createWorkerTimersWorker());

const intervalId = setInterval(() => {
    // do something many times
}, 100);

clearInterval(intervalId);

const timeoutId = setTimeout(() => {
    // do something once
}, 100);

clearTimeout(timeoutId);
```

Please note the syntax for other build tools may vary.

## Security contact information

To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security). Tidelift will coordinate the fix and disclosure.

---
_Source: https://npm.io/package/worker-timers-broker · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
