Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jochemstoel/nodejs-system-sleep
Sleep function for Node.js All platforms.
https://github.com/jochemstoel/nodejs-system-sleep
linux nodejs osx sleep system windows
Last synced: 16 days ago
JSON representation
Sleep function for Node.js All platforms.
- Host: GitHub
- URL: https://github.com/jochemstoel/nodejs-system-sleep
- Owner: jochemstoel
- License: unlicense
- Created: 2015-10-29T18:24:31.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2020-09-28T07:00:06.000Z (over 4 years ago)
- Last Synced: 2024-12-07T12:27:27.877Z (28 days ago)
- Topics: linux, nodejs, osx, sleep, system, windows
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/system-sleep
- Size: 534 KB
- Stars: 51
- Watchers: 3
- Forks: 8
- Open Issues: 7
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# Node.js Sleep()
for those who need Sleep() just like me.![Sleeping Beauty](https://68.media.tumblr.com/02cbcb04de3577bc89ef3c98fdbc94ab/tumblr_oknt65m0Iv1ru9jhqo1_1280.jpg)
*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
```bash
npm install system-sleep
```
### Use
```javascript
var sleep = require('system-sleep');
sleep(5000); // 5 seconds
```
### Test
Prints variable y to the console every 1 second during 10 seconds.
```javascript
var sleep = require('system-sleep');
for (y = 0; y < 10; y++) {
console.log(y);
sleep(1000);
}
```