# asleep

> Non-blocking sleep in ES7 (or, in ES6, setTimeout as a promise).

Latest version **1.0.3** (published 2016-05-05) · MIT license · 0 weekly downloads

## Install

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

## 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 | 1.0.3 |
| Published | 2016-05-05 |
| First published | 2016-05-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=4.0 |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Thomas Frank |
| Maintainers | ironboy |

## Links

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

## Recent versions

- 1.0.3 (latest) — 2016-05-05
- 1.0.2 — 2016-05-05
- 1.0.1 — 2016-05-03
- 1.0.0 — 2016-05-03

## README

# asleep 1.0.3

Non-blocking sleep in ES7 (or, in ES6, setTimeout as a promise). 

This is mostly a syntactic alternative to *setTimeout* in ES6, but in ES7 combined with a loop it will provide a syntactically cleaner alternative to *setInterval*.

> Due to the very limited code base of this module, we do not anticipate needing to make very many changes to it. 

## Require the module
```javascript
var asleep = require("asleep");
```

## Usage in ES6

```javascript
// Sleep for 2 seconds (2000 ms), then do something
asleep(2000).then(function(){
  console.log('Waking up!');
});
```

## Usage in ES7

```javascript
// Inside any async function:
// Sleep for 2 seconds (2000 ms), then do something
await asleep(2000);
console.log('Waking up!');
```

### Example 2
```javascript
// Inside any type of loop in any async function:
while(1){
  await asleep(1000);
  console.log('I say: "Hi" every second!');
}
```
**Please note:** This is non-blocking, other code will continue to run while your async function "sleeps". 

[Read more about async...await](https://www.twilio.com/blog/2015/10/asyncawait-the-hero-javascript-deserved.html)

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