npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

battery-cycle-tracker

v1.0.1

Published

Track lithium-ion cycle count and remaining useful capacity from charge sessions or SoC deltas.

Readme

battery-cycle-tracker

Small ES2015 module that counts equivalent full charge cycles on a lithium-ion cell from a stream of charge or discharge sessions. Written for use inside internal battery-health dashboards.

What it does

The cycle count on a lithium-ion cell is not "how many times it was plugged in" — it is the sum of fractional discharges summing to 100%. A phone discharged from 100% to 75% four times has used one cycle, not four. This tracker sums fractional sessions and increments a full-cycle counter each time the sum crosses 1.0. That is the same math used inside a battery-management IC.

Install

npm install battery-cycle-tracker

Example

const { BatteryCycleTracker } = require('battery-cycle-tracker');

const t = new BatteryCycleTracker({ ratedCycles: 500 });
t.addSession({ startSoc: 1.0, endSoc: 0.35 });
t.addSession({ startSoc: 0.9, endSoc: 0.55 });
console.log(t.cycles);      // 1
console.log(t.healthPct);   // 99.96
console.log(t.lifeLeft);    // 499

Fields

  • cycles — count of completed equivalent cycles
  • healthPct — linearly degrading percentage capacity
  • lifeLeft — ratedCycles - cycles

The linear degrade model is a simplification; for production use replace degradePerCycle with a fit against your cell's own datasheet. Consumer-grade Li-ion cells typically publish 300–500 rated cycles to 80% capacity; the IEC 61960 standard defines how manufacturers report the number.

Where this comes from

We use this at CairoVolt to project the remaining useful life of the Anker power banks in our stock returns pool, so refurb items get graded honestly.

License

ISC.