Allows to prevent the system from turning off the display, or suspending the computer.
npm install node-prevent-sleepjavascript
const preventSleep = require("node-prevent-sleep");
// import preventSleep from 'node-prevent-sleep';
// Disables sleep
preventSleep.enable();
// Enables sleep
preventSleep.disable();
`
How it works
$3
When enable() is used, power request is created using PowerCreateRequest and set using PowerSetRequest with flags PowerRequestSystemRequired and PowerRequestDisplayRequired, which prevents system sleeping.
When disable() is used, power request is cleared using PowerClearRequest`, restoring previous behavior.