Package Exports
- sleep
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (sleep) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
sleep
Add sleep(), msleep() and usleep() to Node.js, via a C++ binding.
This is mainly useful for debugging.
These calls will block execution of all JavaScript by halting Node.js' event loop!
Alternative
When using nodejs 9.3 or higher it's better to use Atomics.wait which doesn't require compiling this C++
module.
The sleep and msleep functions can be implemented like this:
function msleep(n) {
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, n);
}
function sleep(n) {
msleep(n*1000);
}If you require usleep this module is still required.
Usage
var sleep = require('sleep');sleep.sleep(n): sleep fornsecondssleep.msleep(n): sleep fornmilisecondssleep.usleep(n): sleep fornmicroseconds (1 second is 1000000 microseconds)
