Skip to content

Commit

Permalink
Releasing version 2
Browse files Browse the repository at this point in the history
  • Loading branch information
Malick-Tammal committed May 24, 2024
1 parent 7eee046 commit ccf731d
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 5 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog


## Major release - Version 2

> New features release
## Features introduced

- Adding batteryState() battery level | isCharging
- More lightweight and reliable

## Major release - Version 1

> initial release
Expand All @@ -16,6 +26,7 @@

| Version | Date | Comment |
| ------- | --------- | ----------------------------------------------------------- |
| 2.1.4 | 2024-5-24 | Adding batteryState() battery level | isCharging |
| 1.1.4 | 2024-5-17 | Changing batteryData() to batteryInfo() |
| 1.1.3 | 2024-5-02 | Making the code more reliable / adding better error handler |
| 1.0.3 | 2024-4-26 | Deleting file shouldn't be there |
Expand Down
56 changes: 52 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,15 @@

- Get battery health (Accurate reads)
- Get battery information (Serial number , Battery id , Capacity ..)
- Battery realtime level
- Lightweight and reliable

## 🚀 Features will added

- Cross platform support
- Getting laptop model
- Getting Battery Model
- Battery realtime level
- Battery realtime level (added)
- Estimated time for full charge
- Estimated time to fully discharge

Expand All @@ -80,7 +81,7 @@ import the package
const bu = require("battery_util");
```

get battery information
### Get battery information

```js
const bu = require("battery_util");
Expand All @@ -104,7 +105,7 @@ bu.batteryInfo()
// serialNumber : 204
```

get specific data
### Get specific data

```js
const bu = require("battery_util");
Expand All @@ -115,7 +116,7 @@ bu.batteryInfo()
})
.catch(err => {
console.log(err);
});
});
```

### data options :
Expand All @@ -130,6 +131,53 @@ bu.batteryInfo()
- serialNumber
- more in the future ....

### Get battery state

```js
const bu = require("battery_util");

bu.batteryState()
.then(data => {
console.log(data);
}).catch(err => {
console.log(err);
});
```

### Get battery state avery second

```js
const bu = require("battery_util");

setInterval(() => {
bu.batteryState()
.then(data => {
console.log(data);
}).catch(err => {
console.log(err);
});
}, 1000);
```

### Get specific data

```js
const bu = require("battery_util");

bu.batteryState()
.then(data => {
console.log(data.level); // (Example) 78
}).catch(err => {
console.log(err);
});
```

### data options :

- level
- isCharging


## 📖 How it works

With the help of [Child Process](https://www.npmjs.com/package/childprocess) package we can execute a powershell commend and return data from it (Microsoft battery report)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "battery_util",
"version": "1.1.4",
"version": "2.1.4",
"description": "nodeJS package to get information about laptop battery",
"main": "./lib/index.js",
"types": "./lib/index.d.ts",
Expand Down

0 comments on commit ccf731d

Please sign in to comment.