Detects when the system wakes up from standby
(Improved version of sleeptime)
const SleepTime2 = require('sleeptime2')
function onWakeUp (diff, now) {
console.log('The system was asleep for ~%s', diff)
console.log('Time now: %s', now)
console.log('Time at last check: %s', now - diff)
}
const wakeUpTimer = new SleepTime2(onWakeUp)
console.log(wakeUpTimer)
- onWakeUp: Function called if the time difference between the last check and now is bigger than maxDiff
- maxDiff: Amount of milliseconds that the machine needs to be asleep for the event to trigger
Spawns a fork that watches the time
Automatically called after creation
Kills the fork if any is running