FitnessJS

A library for body composition, cardiovascular, and strength estimation and athletic performance prediction.

FitnessJS is a functions for performing all types of peer-reviewed exercise-related calculations ranging from anthropometry calculations to running performance prediction. These functions and classes are built to be modular, so that your source code will not need to be modified to to swap in a new formula.

FitnessJS is implemented in Typescript and includes Typescript declarations for writing safer code and preventing errors early.

Anthropometry

Estimating the height of the body based on the length of other anatomical parts, and vice versa

Anthropometry involves measurement of the physical properties of the human body. Currently, the anthropometric calcultions focus on estimating the height of a human based on other measures of the human body and estimating other measures from the total height. These calculation can be useful for determining the dimensions of a person's body based on incomplete information.

Cardiovascular

Cardiac, Energy Expenditure, and Respiratory calculations

Cardiac

A collection of estimator functions for estimating HRmax and other heart-related formulas. HRmax is important in exercise and personal training as an intensity and safety metric. The closer a person's heart rate is to their HRmax the harder they are exerting themselves, and will have a higher energy expenditure. Older adults tend to be at higher-risk of a heart attach and must ensure that their heart rates do not come within a given range of their HRmax to avoid potential heart attacks.

All estimators are class definitions that implement the same interface:

interface Estimator {
    predict(dob: Date); // returns hearted rates in beats per minute (BPM)

    age(hr: number); // returns age in years

}

This consistent interface is intended, so developers can more easily write applications that can dynamically use different Estimator classes to perform the estimation based on the demographics of the individual.

Energy

A collection of formulas that estimate the caloric needs of the body such as BMR, RMR, and more.

All BMR estimators are class definitions that implement the same interface:

class BMREstimator {
      public gender: Gender;

      constructor(gender: Gender) {
        this.gender = gender;
      }

      predict(dob: Date, weight: number, height: number): number {
        return bmrInKilocalories;
      }

}

where gender is one of Fit.Gender.Male or Fit.Gender.Female.

All estimators are class definitions that implement the same interface as well:

function TEEEstimator(gender, pal) {
    this.gender = gender;
    this.pal = pal;
}

TEEEstimator.prototype.predict = function(dateOfBirth, weight, height) {
    return teeInKilocalories;
}

class TEEEstimator {
    public gender: Gender;
    public pal: PAL;

    constructor(gender: Gender, pal: PAL) {
        this.gender = gender;
        this.pal = pal;
    }

    predict(dob: Date, weight: number, height: number): number {
        return teeInKilocalories;
    }

    fromActivity(weight: number, mets: number): number {
        return teeInKilocalories;
    }
}

where a pal is one of Fit.PAL.Sedentary, Fit.PAL.Low, Fit.PAL.Active, or Fit.PAL.VeryActive.

Respiration

A collection of calculations for estimating Residual Volume of the lungs, and estimating VO2max based off of clinical exercise tests. For more information on the testing protocols see the Test Protocols in the wiki.

Composition

Calculations involving the body composition, or for calculating body composition

density

A collection of calcuations for estimating the density of the body using skinfold tests. The method to be used to return the density depends on the age, race, and lifestyle factors of the individual.

Fat

A collection of calculations for estimating the body fat percentage of an individual based on body-density, or BMI.

Ideal

A collection of estimating ideal body factors such as weight, or waist circumference based on gender, height, and weight.

Warning

Please keep in mind that these are estimations and are not always accurate. A person's body can be perfectly healthy and not match the output produced by these calculations. Therefore individuals should not turn to unhealthy behaviors to change their body to match those of these estimations. Please consult a health professional regarding altering behaviors.

Index

A collection of metrics used for normalizing body weight assessments. Indices include BMI, BMIPrime, BAI, and the Corpulence Index

Mass

A collection of calculations for estimating FFM across demographics and is a primary determinant of REE. FFM can be better than total body weight for prescribing levels of medications and for assessing metabolic disorders.

Stature

A couple of metrics used for estimating skeleton stature of an individual based on total height, age and gender. Also includes a calculation for estimating stride length based on height and gender.

Surface Area

A collection of calcuations forestimating the surface area of an individuals body based on gender, age, weight, and height. Surface area has a few uses and can be a better indicator of daily energy expenditure than body mass because it is less affected by abnormal fat stores.

Conversion

For making unit conversions painless

The library includes logic for easily performing unit conversions.

  • SwainConverter for converting between VO2 Max and Percent HRMax
  • UnitConverter for standard unit conversion. Here is an example of converting meters to feet:

    let convertedValue: number =  new Fit.conversion.UnitConverter(1609.34, 'm').to('feet').val();  // 5280

    This converter can be extended dynamically to include more units using the addUnit static method.

  • TemperatureConverter for temperature conversion between Farenheit, Celsius, and Kelvin. This can used similarly to the UnitConverter:

    let convertedTemperature: number =  new Fit.conversion.TemperatureConverter(32, 'F').to('C').val() // convert Farenheit to Celsius

Models

Models that have a proven use-case for estimation

Aerobic

A collection of models for prediction performance across aerobic sports, such as the Riegel and Cameron models.

The Riegel and Cameron models inherit from the PerformanceModel class:

abstract class PerformanceModel {
    protected t1: number;
    protected d1: number;

    constructor(d1: number, t1: number) {
      this.d1 = d1;
      this.t1 = t1;
    }

    time(d2: number): number { return 0}

    distance(t2: number): number { return 0}

}

where t1 and d1 correspond to the time and distance of a base-line performance. t2 and d2 correspond to the time and distance of the predicted performance. By using the same interface, the Riegel and Cameron models can be used interchangeably.

Note: The Reigel model can be used to predict performances using multiple modes of travel, such as running, swimming, nordic skiing, racewalking, rollerskating, cycling, and speedskating. The Cameron model only supports running performances, and distances must be provided in miles, and time in seconds.

Sport

Running

A collection of a variety of calcuations related to running such as adjusting performances based on external temperature, age grading performances, VO2, pace ranges based on HRmax, and more.

Strength

A collection of calculations related to strength-based performances. Calculations range from comparing performances, to estimating the weight for a given number of repetitions.

All 1-RM estimators are class definitions that implement the same interface as well:

class RMEstimator {
  public reps: number;

    constructor(reps: number) {
        this.reps = reps;
    }

    predict(weight: number): number {
        // calculations ...
        return weightInKilograms;
    }

    static isValid(gender: Gender, age: number, repetitions: number, weight: number): boolean {
        return RMEstimatorSubclassIsValid;
    }
}

where isValid can be used to dynamically determine if an RMEstimator can be applied to a given demographic or performance.