# thread-sleep

> A module for when you just need node to back off for a few milliseconds

Latest version **2.2.0** (published 2019-03-17) · MIT license · 0 weekly downloads

## Install

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

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.2.0 |
| Published | 2019-03-17 |
| First published | 2015-01-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=0.11.12 |
| Dependencies | 0 |
| Unpacked size | 5.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 15 |
| Author | ForbesLindesay |
| Maintainers | forbeslindesay, timothygu |
| Keywords | sleep |

## Links

- npm: https://www.npmjs.com/package/thread-sleep
- Repository: https://github.com/ForbesLindesay/thread-sleep
- Homepage: https://github.com/ForbesLindesay/thread-sleep#readme
- Issues: https://github.com/ForbesLindesay/thread-sleep/issues
- npm.io page: https://npm.io/package/thread-sleep

## Recent versions

- 2.2.0 (latest) — 2019-03-17
- 2.1.0 — 2018-06-01
- 2.0.0 — 2016-12-29
- 1.0.4 — 2015-09-09
- 1.0.3 — 2015-02-11
- 1.0.2 — 2015-02-06
- 1.0.1 — 2015-02-06
- 1.0.0 — 2015-02-05
- 0.0.5 — 2015-02-05
- 0.0.4 — 2015-02-05
- 0.0.3 — 2015-02-05
- 0.0.2 — 2015-02-05
- 0.0.1 — 2015-02-05
- 0.0.0 — 2015-01-15

## README

# thread-sleep

A native module for when you just need node to back off for a few milliseconds.  It effectively pauses the current thread.  It may be woken early if an interupt is fired, so it should work pretty well for busy waiting scenarios where you want to check something every few hunderd milliseconds.

[![Linux and Mac Build Status](https://img.shields.io/travis/ForbesLindesay/thread-sleep/master.svg?label=Linux%20%26%20Mac%20Build)](https://travis-ci.org/ForbesLindesay/thread-sleep)
[![Windows Build Status](https://img.shields.io/appveyor/ci/ForbesLindesay/thread-sleep/master.svg?label=Windows%20Build)](https://ci.appveyor.com/project/ForbesLindesay/thread-sleep)
[![Dependency Status](https://img.shields.io/david/ForbesLindesay/thread-sleep.svg)](https://david-dm.org/ForbesLindesay/thread-sleep)
[![NPM version](https://img.shields.io/npm/v/thread-sleep.svg)](https://www.npmjs.org/package/thread-sleep)

## Installation

    npm install thread-sleep

This module uses node-pre-gyp so it should install even without a compiler in most environments.  If you run into any problems, please open an issue with the full npm log, and a description of what operating system you use.

## Usage

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

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');
// tested on osx and resulted in => 1005 ~= 1010 ~= 1000
```

## License

  MIT

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