keep your computer awake
npm install wake-lockš“š
Prevent your laptop from sleeping. (macOS only for now.)
``js
const {WakeLock} = require('wake-lock')
const lock = new WakeLock("Reticulating splines")
// ... reticulate the splines, which process must not be interrupted ...
lock.release()
`
Creates a new wake lock which will prevent the machine from going to sleep due
to idle detection until the lock is released. Forced sleep, e.g. from closing
the laptop's lid or a low battery emergency, will not be prevented. Multiple
wake locks are allowed: the machine will stay awake until all wake locks are
released.
* reasonForLocking String - a descriptive string used by the system wheneveroptions
it needs to tell the user why the system is not sleeping. For example, "Mail
Compacting Mailboxes" would be a useful string.
* Object _(optional)_type` "idle" | "display" - if "display" is specified, display sleep will
*
be prevented. If "idle" is specified (the default), the display will sleep
but the machine will stay awake while the lock is held.
Releases a wake lock, allowing the machine to sleep. Calling this function on a
lock that has already been released will throw an error.