parent
dd4a31633f
commit
547add94d0
3 changed files with 36 additions and 12 deletions
|
@ -22,4 +22,30 @@ if (process.platform === 'linux') {
|
|||
})
|
||||
}
|
||||
|
||||
// TODO(deepak1556): Deprecate async api in favor of sync version in 5.0
|
||||
powerMonitor.querySystemIdleState = function (threshold, callback) {
|
||||
if (typeof threshold !== 'number') {
|
||||
throw new Error('Must pass threshold as a number')
|
||||
}
|
||||
|
||||
if (typeof callback !== 'function') {
|
||||
throw new Error('Must pass callback as a function argument')
|
||||
}
|
||||
|
||||
const idleState = this._querySystemIdleState(threshold)
|
||||
|
||||
process.nextTick(() => callback(idleState))
|
||||
}
|
||||
|
||||
// TODO(deepak1556): Deprecate async api in favor of sync version in 5.0
|
||||
powerMonitor.querySystemIdleTime = function (callback) {
|
||||
if (typeof callback !== 'function') {
|
||||
throw new Error('Must pass function as an argument')
|
||||
}
|
||||
|
||||
const idleTime = this._querySystemIdleTime()
|
||||
|
||||
process.nextTick(() => callback(idleTime))
|
||||
}
|
||||
|
||||
module.exports = powerMonitor
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue