package
Add sleep() and usleep() to nodejs
npm install sleepGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
Estimated unpacked size across 2 packages.
461.7 kB
Includes dependencies.
Add sleep(), msleep() and usleep() to Node.js, via a C++ binding.
This is mainly useful for debugging.
Note that because this is a C++ module, it will need to be built on the system you are going to use it on.
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.
var sleep = require('sleep');sleep.sleep(n): sleep for n secondssleep.msleep(n): sleep for n milisecondssleep.usleep(n): sleep for n microseconds (1 second is 1000000 microseconds)