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

@dofek/zones

v0.1.4

Published

Heart-rate and cycling-power zone calculations and classification

Readme

@dofek/zones

Framework-neutral heart-rate and cycling-power zone definitions, classification, range formatting, time-distribution mapping, and polarization analysis.

Install

npm install @dofek/zones

Requires Node.js 22.14 or newer.

Usage

import {
  classifyHeartRateZone,
  computePolarizationIndex,
  heartRateZoneBoundaries,
} from "@dofek/zones";

const maxHeartRate = 190;
const restingHeartRate = 55;

console.log(heartRateZoneBoundaries(maxHeartRate, restingHeartRate));
console.log(classifyHeartRateZone(150, maxHeartRate, restingHeartRate));
console.log(computePolarizationIndex(3_600, 300, 600));

Public API

Both @dofek/zones and @dofek/zones/zones expose the same API:

  • Heart-rate definitions, colors, boundaries, classification, range labels, and complete time-in-zone rows.
  • Cycling-power definitions, colors, FTP-relative boundaries, classification, range labels, and complete time-in-zone rows.
  • Generic zone-distribution row and label helpers.
  • Three-zone polarization definitions and computePolarizationIndex.
  • TypeScript interfaces for all definitions, boundaries, rows, and activity zones.

Models and behavior

Heart-rate reserve

The five activity zones use heart-rate reserve:

HRR fraction = (heart rate - resting heart rate) / (maximum heart rate - resting heart rate)

The boundaries are 50–60%, 60–70%, 70–80%, 80–90%, and 90–100% HRR. This model is based on the heart-rate-reserve approach described by Karvonen, Kentala, and Mustala (1957). Readings below the first boundary classify as zone 0.

Polarization index

computePolarizationIndex implements:

PI = log10((f1 / f2) × f3 × 100)

where each f is the fraction of total time in one of the three intensity zones. The function returns null when any zone has no time, which is Dofek's explicit calculation choice, or when Zone 3 exceeds Zone 1, which Treff defines as outside the index's valid range. The formula and descriptive 2.0 heuristic come from Treff et al. (2019). The index describes a recorded training-intensity distribution; it is not a physiological or medical assessment.

Cycling power

The package defines seven FTP-relative cycling-power zones and exposes helpers to convert them into watt boundaries or classify individual power readings.

The package performs no network requests and needs no authentication or runtime configuration. Callers are responsible for supplying valid, individualized maximum/resting heart rates and FTP values. The calculations are training analysis tools, not medical advice.

License and contributing

MIT. Source is in the Dofek repository. Please open an issue for bugs or API proposals, or submit a pull request.