# thread-sleep-compat

> thread-sleep the runs on multiple versions of node

Latest version **1.4.2** (published 2026-09-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install thread-sleep-compat
pnpm add thread-sleep-compat
yarn add thread-sleep-compat
bun add thread-sleep-compat
```

## 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 | 1.4.2 |
| Published | 2026-09-12 |
| First published | 2022-07-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=0.8 |
| Dependencies | 1 |
| Unpacked size | 363.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | kmalakoff |
| Keywords | thread-sleep, thread, sleep |

## Links

- npm: https://www.npmjs.com/package/thread-sleep-compat
- Repository: https://github.com/kmalakoff/thread-sleep-compat
- Issues: https://github.com/kmalakoff/thread-sleep-compat/issues
- npm.io page: https://npm.io/package/thread-sleep-compat

## Dependencies (1)

- [thread-sleep](https://npm.io/package/thread-sleep.md) ^2.2.0

## Recent versions

- 1.4.2 (latest) — 2026-09-12
- 1.4.1 — 2026-09-03
- 1.4.0 — 2026-09-03
- 1.3.3 — 2026-08-31
- 1.3.2 — 2026-05-26
- 1.3.1 — 2025-12-18
- 1.3.0 — 2025-12-18
- 1.2.0 — 2025-12-18
- 1.1.7 — 2025-12-15
- 1.1.6 — 2025-12-15
- 1.1.5 — 2025-12-12
- 1.1.4 — 2025-12-12
- 1.1.3 — 2025-12-12
- 1.1.2 — 2025-12-12
- 1.1.1 — 2025-12-11
- … 43 more at https://npm.io/package/thread-sleep-compat/versions

## README

# thread-sleep-compat

Synchronous thread sleep for Node.js 0.8 and newer.

Please see the original [thread-sleep](https://github.com/ForbesLindesay/thread-sleep.git) module for details.

## Installation

```sh
npm install thread-sleep-compat
```

## Usage

```js
var sleep = require('thread-sleep-compat');

var start = Date.now();
var res = sleep(1000);
var end = Date.now();
// res is the actual time that we slept for
console.log(res + ' ~= ' + (end - start) + ' ~= 1000');
// Example output: 1005 ~= 1010 ~= 1000
```

`sleep(ms)` blocks the current thread and returns the actual sleep duration in milliseconds. It throws when `ms` is negative, non-integer, outside the supported range, or not a number.

Node 0.x versions below 0.12 use bundled native binaries. Newer Node versions use the `thread-sleep` dependency.

## License

MIT

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