# rolex

> Drift-minimizing setInterval replacement and high-precision timer utility for Node and browser

Latest version **1.1.2** (published 2017-10-20) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install rolex
pnpm add rolex
yarn add rolex
bun add rolex
```

Provides the command `timer-comparison`.

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.1.2 |
| Published | 2017-10-20 |
| First published | 2015-01-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 85 |
| Author | Dan Kaplun |
| Maintainers | dbkaplun |
| Keywords | setInterval, setTimeout, precise, accurate, drift |

## Links

- npm: https://www.npmjs.com/package/rolex
- Repository: https://github.com/dbkaplun/rolex
- Homepage: https://github.com/dbkaplun/rolex#readme
- Issues: https://github.com/dbkaplun/rolex/issues
- npm.io page: https://npm.io/package/rolex

## Dependencies (1)

- [present](https://npm.io/package/present.md) ^0.0.3

## Recent versions

- 1.1.2 (latest) — 2017-10-20
- 1.1.1 — 2017-10-20
- 1.1.0 — 2017-10-20
- 1.0.0 — 2016-04-12
- 0.0.1 — 2015-01-10
- 0.0.0 — 2015-01-10

## README

# rolex [![rolex on npm](https://img.shields.io/npm/dm/rolex.svg?maxAge=2592000)](https://www.npmjs.com/package/rolex) [![build status](https://img.shields.io/travis/dbkaplun/rolex.svg?maxAge=2592000)](https://travis-ci.org/dbkaplun/rolex)

Drift-minimizing setInterval replacement and high-precision timer utility for Node and browser

![Comparison between setInterval, rolex, and recursive setTimeout](timer-comparison.gif)

## How it works

To ensure maximal accuracy compared with setTimeout, Rolex calls setTimeout *in advance* of the requested timeout, then checks how close the requested timeout
is. It does this recursively until the timeout is reached within a given
threshold. Both the `aggression` and `threshold` are user-configurable.

## Installation

In Node: `npm install rolex`

In browser:

1. Copy `rolex.js` or `rolex.min.js` (with optional source map at `rolex.min.js.map`)
2. `<script src="path/to/rolex.{min.}js"></script>`
3. `setInterval` and `clearInterval` are automatically replaced -- if this is undesired, `Rolex.noConflict();`

## Usage

```js
var Rolex = require('rolex')
var r = Rolex(10, () => {
  console.log('executes in 10 ms')
}).start()
```

More examples in [test/rolex.js](test/rolex.js).

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