New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

asleep

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

asleep

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

1.0.3
latest
Source
npm
Version published
Weekly downloads
115
-10.85%
Maintainers
1
Weekly downloads
 
Created
Source

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

var asleep = require("asleep");

Usage in ES6

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

Usage in ES7

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

Example 2

// 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

FAQs

Package last updated on 05 May 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts