Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

osx-is-charging

A zero-dependency utility to check if a Mac is connected to a power outlet or running on battery. This is a lightweight replacement for is-charging, which has 27 dependencies and critical vulnerabilities that cannot be patched.

This utility is useful if your application needs to know whether it can run in full capacity (drawing lots of power) or if it should switch to a low-capacity mode.

Features

  • Zero dependencies
  • Safe and secure
  • Simple API

Installation

npm install telia-oss/osx-is-charging

Usage

import { isCharging } from 'osx-is-charging';

async function checkChargingStatus() {
  try {
    const charging = await isCharging();
    console.log('Is charging:', charging);
  } catch (error) {
    console.error('Error:', error.message);
  }
}

checkChargingStatus();

Example

See example.js for a complete example.

License

MIT

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages