@hyperlink/ups-status
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

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!

Package Sidebar

Install

npm i @hyperlink/ups-status

Weekly Downloads

0

Version

1.0.1

License

MIT

Unpacked Size

9.37 kB

Total Files

11

Last publish

Collaborators

  • hyperlink