Allows to prevent the system from turning off the display, or suspending the computer.
const preventSleep = require("node-prevent-sleep");
// import preventSleep from 'node-prevent-sleep';
// Disables sleep
preventSleep.enable();
// Enables sleep
preventSleep.disable();
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.
Not supported yet. You are welcome to submit a PR with the functionality.
Not supported yet. You are welcome to submit a PR with the functionality.
MIT