Make //ui/base/idle API synchronous

1379183
This commit is contained in:
deepak1556 2019-01-22 16:43:22 +05:30
parent dd4a31633f
commit 547add94d0
3 changed files with 36 additions and 12 deletions

View file

@ -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