I\'m currently trying to learn nodejs and a small project I\'m working is writing an API to control some networked LED lights.
The microprocessor controlling the LED
Just use child_process.execSync
and call the system's sleep function.
//import child_process module
const child_process = require("child_process");
// Sleep for 5 seconds
child_process.execSync("sleep 5");
// Sleep for 250 microseconds
child_process.execSync("usleep 250");
// Sleep for a variable number of microseconds
var numMicroSeconds = 250;
child_process.execFileSync("usleep", [numMicroSeconds]);
I use this in a loop at the top of my main application script to make Node wait until network drives are attached before running the rest of the application.