Skip to content

hyperlink/ups-status

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

UPS Status 🔌 for Node JS

Version License: ISC Twitter: hyperlink

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 javascript@yahoo.com

Show your support

Give a ⭐️ if this project helped you!

About

Node.Js API to get status of UPS connected to your MacOS

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published