
Security News
Package Maintainers Call for Improvements to GitHub’s New npm Security Plan
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
ember-battery
Advanced tools
Battery status API packaged as a Service
Inject the battery
service in your classes and access its api:
export default class ApplicationController extends Controller {
@service battery;
get isTooLow() {
return !this.battery.isCharging && this.battery.level < 0.2;
}
get iconName() {
let level = this.battery.level;
if (level < 0.02) {
return 'battery-0';
} else if (level < 0.25) {
return 'battery-1';
} else if (level < 0.5) {
return 'battery-2';
} else if (level < 0.75) {
return 'battery-3';
} else {
return 'battery-4';
}
}
}
Or use them directly in the templates:
{{#if this.battery.isSupported}}
<p>{{this.battery.levelPercentage}}% {{fa-icon this.iconName}}</p>
{{#if this.battery.isCharging}}
<p>Your battery is charging!</p>
{{/if}}
{{#if this.isTooLow}}
<p>Your battery is too low!</p>
{{/if}}
<p>Discharging Time: {{this.battery.dischargingTime}}</p>
<p>Charging Time: {{this.battery.chargingTime}}</p>
{{else}}
<p>Your browser does not support battery status API.</p>
{{/if}}
Because the properties are @tracked
, the templates and getters will update accordingly when the properties change.
The battery service has the following properties:
isSupported
- A Boolean value indicating whether or not the supports the battery status API.isCharging
- A Boolean value indicating whether or not the battery is currently being charged.level
- A number representing the system's battery charge level scaled to a value between 0.0 and 1.0.chargingTime
- A number representing the remaining time in seconds until the battery is fully charged, or 0 if the battery is already fully charged.dischargingTime
- A number representing the remaining time in seconds until the battery is completely discharged and the system will suspend.levelPercentage
- A number representing the system's battery charge level scaled to a value between 0 % and 100 %ember install ember-battery
See the Contributing guide for details.
This project is licensed under the MIT License.
FAQs
Battery status API packaged as a Service
The npm package ember-battery receives a total of 0 weekly downloads. As such, ember-battery popularity was classified as not popular.
We found that ember-battery demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
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.
Security News
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
Product
Socket Firewall is a free tool that blocks malicious packages at install time, giving developers proactive protection against rising supply chain attacks.
Research
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.