New: Introducing PHP and Composer Support.Read the Announcement
Socket
Book a DemoInstallSign in
Socket

browser-battery

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

browser-battery

Get and watch battery information in a browser

latest
Source
npmnpm
Version
2.0.0
Version published
Weekly downloads
155
0.65%
Maintainers
1
Weekly downloads
 
Created
Source

browser-battery

Get and watch battery information in a browser

Currently working in Chrome, Firefox and Opera.

Install

$ npm install --save browser-battery

Usage

const browserBattery = require('browser-battery');

browserBattery().then(battery => {
	console.log(battery);
	/*
	{
		charging: false
		chargingTime: Infinity
		dischargingTime: 11160
		level: 0.6
		onchargingchange: null
		onchargingtimechange: null
		ondischargingtimechange: null
		onlevelchange: null
	}
	 */
});

// Use the event listeners
browserBattery().then(battery => {
	battery.onlevelchange = function () {
		console.log(battery.level);
		//=> 0.89
	};
});
  • battery-level - Get current battery level (OS X, Linux and Windows)

License

MIT © Andreas Gillström

Keywords

battery

FAQs

Package last updated on 08 Jan 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts