system-sleep
DefinitelyTyped icon, indicating that this package has TypeScript declarations provided by the separate @types/system-sleep package

1.3.7 • Public • Published

Node.js Sleep()

for those who need Sleep() just like me.

Sleeping Beauty

31 january 2017 | UPDATE: NO LONGER REQUIRES CHILD PROCESS, using deasync instead.

 @package system-sleep
 @version 1.2
 @author Jochem Stoel (http://jochemstoel.github.io)
 @license don't involve me
  • will make the system wait xxx milliseconds.

  • can be used to delay script execution.

  • is often used to relax the system in between resource intensive tasks.

  • works on every platform x86 + x64 Windows / Linux / OSX

  • Existing sleep() solutions use a blocking while loop which uses 100% CPU. This is incredibly stupid.

  • Also, many sleep() solutions are only for Windows or only for Linux.

Install using NPM

npm install system-sleep

Use

var sleep = require('system-sleep');
sleep(5000); // 5 seconds

Test

Prints variable y to the console every 1 second during 10 seconds.

var sleep = require('system-sleep');
for (= 0; y < 10; y++) {
    console.log(y);
    sleep(1000);
}
Jochem Stoel

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.3.7
    3,468
    • latest

Version History

Package Sidebar

Install

npm i system-sleep

Weekly Downloads

3,991

Version

1.3.7

License

none

Unpacked Size

3.79 kB

Total Files

4

Last publish

Collaborators

  • jochemstoel