@hyperlink/ups-status
v1.0.1
Published
Node.Js API to get status of UPS connected to your MacOS
Downloads
10
Maintainers
Readme
UPS Status 🔌 for Node JS
Node.Js API to get status of UPS connected to your MacOS
Install
npm install @hyperlink/ups-status
Usage
Two different ways to use this module. You can Promise interface or EventEmitter interface.
Promise interface
import { isOnBattery, isOnAc } from '@hyperlink/ups-status';
// in some async function
if (await isOnBattery()) {
console.log('Mac is running on Battery');
} else {
console.log('Mac is on AC');
}
// or
// in some async function
if (await isOnAc()) {
console.log('Mac is on AC');
} else {
console.log('Mac is running on Battery');
}
EventEmitter interface.
UpsEmitter
will emit 'ac'
event with true
or false
value when AC is connected or not.
import { UpsEmitter } from '@hyperlink/ups-status';
const ups = new UpsEmitter();
ups.on('ac', isOnAc => console.log('computer is on ac:', isOnAc));
Author
👤 Xiaoxin Lu [email protected]
- Twitter: @hyperlink
- Github: @hyperlink
Show your support
Give a ⭐️ if this project helped you!