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/training

v0.1.4

Published

Training-science calculations for power, load, performance, and workout planning

Readme

@dofek/training

Framework-neutral TypeScript calculations for training load, cycling power, performance modeling, activity normalization, and workout recommendations.

Install

npm install @dofek/training

Requires Node.js 22.14 or newer.

Usage

There is no root export; import the module subpath you need.

import {
  computeHrTss,
  computeTrimp,
} from "@dofek/training/pmc";

const durationMinutes = 60;
const averageHeartRate = 150;
const maximumHeartRate = 190;
const restingHeartRate = 55;

console.log({
  trimp: computeTrimp(
    durationMinutes,
    averageHeartRate,
    maximumHeartRate,
    restingHeartRate,
  ),
  hrTss: computeHrTss(
    durationMinutes,
    averageHeartRate,
    maximumHeartRate,
    restingHeartRate,
  ),
});

Public API

Every public module is imported as @dofek/training/<subpath>.

| Subpath | Purpose | | --- | --- | | activity-icons | Normalize activity names into framework-neutral icon categories | | climbing-grades | Parse V-scale and Yosemite Decimal System climbing grades | | derived-cardio | Cycling and submaximal walking/running VO2 max estimates and validation | | endurance-types | Endurance and indoor-cycling type guards | | grade-adjusted-pace | Grade cost factor and adjusted running pace | | muscle-groups | Muscle-group expansion, totals, intensities, and display colors | | pmc | TRIMP, heart-rate/power stress, FTP estimate, learned stress model, and performance-management calculations | | power-analysis | Power curves, normalized power, critical-power fit, regression, and duration constants | | training | Canonical activity types, provider normalization, and weekly-volume grouping | | training-distribution | Karvonen and Treff weekly intensity-distribution summaries | | training-load | TrainingStressCalculator stateful facade | | workout-recommendation | Workout recommendation types and calculation |

Model details

Training distributions

The Treff polarization summary uses recorded cycling time in three maximum-heart-rate zones and the published formula log10((f1 / f2) × f3 × 100), where f1, f2, and f3 are the fractions of total recorded cycling time in Zone 1, Zone 2, and Zone 3 respectively. Dofek requires recorded time in every zone instead of applying the paper's zero-Zone-2 substitution and follows the paper's rule that the index is invalid when Zone 3 exceeds Zone 1. The > 2.00 comparison is presented as a descriptive training-distribution heuristic, not a physiological or medical assessment. See Treff et al. (2019).

Workout recommendations

recommendNextWorkout combines recent activity, readiness, muscle-group freshness, and intensity distribution. Its low/moderate/high distribution model is informed by the three-zone observations in Seiler and Kjerland (2006); the exact readiness gates, recovery windows, and recommendation rules are Dofek product heuristics.

Training stress and performance

  • computeTrimp applies the package's exponential heart-rate-load formula.
  • computeHrTss normalizes that load to the package's one-hour threshold reference.
  • Power stress uses duration, FTP, and normalized power.
  • Stress-model helpers fit a personal linear relationship from paired heart-rate and power observations.
  • FTP estimation uses 95% of the best 20-minute average power, matching the TrainingPeaks threshold procedure.

Power and curve analysis

  • Power curves use prefix sums to find the best average power across the package's standard durations.
  • Normalized power uses 30-second rolling averages and fourth-power weighting, following the TrainingPeaks calculation.
  • Critical power fits the two-parameter relationship introduced by Monod and Scherrer (1965) using efforts from 120 through 600 seconds.

Terrain adjustment

Grade-adjusted pace uses a bounded approximation derived from the slope-cost work of Minetti et al. (2002). It is an estimate, not a substitute for measured effort.

Activity normalization

Canonical activity types map provider-specific labels into one vocabulary. Endurance filters and weekly-volume grouping keep downstream analysis provider-neutral.

Errors and configuration

The package performs no network requests and requires no authentication or environment variables. Several calculations return zero or null when data is invalid or insufficient; callers should validate data at external boundaries and handle the nullable return types declared by each function. Training calculations are estimates and are 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.