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 🙏

© 2024 – Pkg Stats / Ryan Hefner

health-calculator

v1.0.0

Published

A library to help calculate well known health-related metrics.

Downloads

238

Readme

health-calculator

A library to help calculate well known health-related metrics.

Install

npm i health-calculator

Usage

import { dietary } from 'health-calculator';

console.log( dietary.tdee( 'male', 20, 80, 180, 'moderate' ) );

or:

import { tdee } from 'health-calculator/dietary';

console.log( tdee( 'male', 20, 80, 180, 'moderate' ) );

See API reference for more.

API Reference

Modules

body_measurement

body_measurement~bmi(weight, height, imperial) ⇒ number

Calculates body mass index (BMI).

Kind: inner method of body_measurement
Returns: number - BMI.

| Param | Type | Description | | --- | --- | --- | | weight | number | Weight of a person. | | height | number | Height of a person. | | imperial | boolean | Flag to use imperial (lb and inch). Default to use metric (kg and cm). |

body_measurement~whtr(waistCircumference, height, imperial) ⇒ number

Calculates waist-to-height ratio (WHtR).

Kind: inner method of body_measurement
Returns: number - WHtR.
See: https://en.wikipedia.org/wiki/Waist-to-height_ratio

| Param | Type | Description | | --- | --- | --- | | waistCircumference | number | Waist circumference of a person. | | height | number | Height of a person. | | imperial | boolean | Flag to use imperial (lb and inch). Default to use metric (kg and cm). |

body_measurement~whtrCategory(gender, age, ratio) ⇒ BodyCategory

Categorize the boundaries for WHtR in terms of their health implications.

Kind: inner method of body_measurement
Returns: BodyCategory - Category.
See: https://en.wikipedia.org/wiki/Waist-to-height_ratio#Health_implications

| Param | Type | Description | | --- | --- | --- | | gender | Gender | 'male' or 'female'. | | age | number | Age between 18 and 120. | | ratio | number | WHtR. |

body_measurement~whtrChildren(ratio) ⇒ BodyCategory

WHtR category for children (up to 15 yeard old).

Kind: inner method of body_measurement
Returns: BodyCategory - Category.

| Param | Type | Description | | --- | --- | --- | | ratio | number | WHtR. |

body_measurement~whtrMale(ratio) ⇒ BodyCategory

WHtR category for adult male.

Kind: inner method of body_measurement
Returns: BodyCategory - Category.

| Param | Type | Description | | --- | --- | --- | | ratio | number | WHtR. |

body_measurement~whtrFemale(ratio) ⇒ BodyCategory

WHtR category for adult female.

Kind: inner method of body_measurement
Returns: BodyCategory - Category.

| Param | Type | Description | | --- | --- | --- | | ratio | number | WHtR. |

body_measurement~whr(waistCircumference, hipCircumference, imperial) ⇒ number

Calculates waist-to-hip ratio (WHR).

Kind: inner method of body_measurement
Returns: number - WHR.
See: https://en.wikipedia.org/wiki/Waist%E2%80%93hip_ratio

| Param | Type | Description | | --- | --- | --- | | waistCircumference | number | Waist circumference of a person. | | hipCircumference | number | Hip circumference of a person. | | imperial | boolean | Flag to use imperial (lb and inch). Default to use metric (kg and cm). |

body_measurement~bfp(gender, age, bmi) ⇒ number

Calculates body fat percentage (BFP) using BMI.

Kind: inner method of body_measurement
Returns: number - BFP.
See: https://en.wikipedia.org/wiki/Body_fat_percentage#From_BMI

| Param | Type | Description | | --- | --- | --- | | gender | Gender | 'male' or 'female'. | | age | number | Age between 18 and 120. | | bmi | number | BMI result. |

body_measurement~lbm(gender, weight, height, imperial) ⇒ number

Calculates lean body mass (LBM) using the Boer formula.

Kind: inner method of body_measurement
Returns: number - LBM.
See: https://en.wikipedia.org/wiki/Lean_body_mass#Boer[3]

| Param | Type | Description | | --- | --- | --- | | gender | Gender | 'male' or 'female'. | | weight | number | Weight of a person. | | height | number | Height of a person. | | imperial | boolean | Flag to use imperial (lb and inch). Default to use metric (kg and cm). |

body_measurement~rfm(gender, height, waistCircumference, imperial) ⇒ number

Calculates relative fat mass (RFM).

Kind: inner method of body_measurement
Returns: number - RFM.

| Param | Type | Description | | --- | --- | --- | | gender | Gender | 'male' or 'female'. | | height | number | Height of a person. | | waistCircumference | number | Waist circumference of a person. | | imperial | boolean | Flag to use imperial (lb and inch). Default to use metric (kg and cm). |

body_measurement~ffmi(weight, height, bodyFat, imperial) ⇒ number

Calculates fat-free mass index (FFMI).

Kind: inner method of body_measurement
Returns: number - FFMI.

| Param | Type | Description | | --- | --- | --- | | weight | number | Weight of a person. | | height | number | Height of a person. | | bodyFat | number | Body fat percentage. | | imperial | boolean | Flag to use imperial (lb and inch). Default to use metric (kg and cm). |

dietary

dietary~bmr(gender, age, weight, height, imperial, equation) ⇒ number

Calculates basal metabolic rate (BMW); the number of calories our body needs to accomplish its most basic (basal) life-sustaining functions.

Kind: inner method of dietary
Returns: number - BMI.

| Param | Type | Description | | --- | --- | --- | | gender | Gender | 'male' or 'female'. | | age | number | Age between 18 and 120. | | weight | number | Weight between 15kg and 635kg. | | height | number | Height of a person. | | imperial | boolean | Flag to use imperial (lb and inch). Default to use metric (kg and cm). | | equation | BmrEquation | Equation to use ('harrisBenedict', 'rozaAndShizgal', or 'mifflin'). Default to 'mifflin'. |

dietary~bmrHarrisBenedict(gender, age, weight, height) ⇒ number

Calculates BMR using Harris-Benedict equation.

Kind: inner method of dietary
Returns: number - BMR.
See: https://en.wikipedia.org/wiki/Harris%E2%80%93Benedict_equation

| Param | Type | Description | | --- | --- | --- | | gender | Gender | 'male' or 'female'. | | age | number | Age between 18 and 120. | | weight | number | Weight between 15kg and 635kg. | | height | number | Height of a person. |

dietary~bmrRozaAndShizgal(gender, age, weight, height) ⇒ number

Calculates BMR using revised Harris-Benedict equation by Roza and Shizgal.

Kind: inner method of dietary
Returns: number - BMR.
See: https://en.wikipedia.org/wiki/Harris%E2%80%93Benedict_equation

| Param | Type | Description | | --- | --- | --- | | gender | Gender | 'male' or 'female'. | | age | number | Age between 18 and 120. | | weight | number | Weight between 15kg and 635kg. | | height | number | Height of a person. |

dietary~bmrMifflin(gender, age, weight, height) ⇒ number

Calculates BMR using revised Harris-Benedict equation by Mifflin.

Kind: inner method of dietary
Returns: number - BMR.
See: https://en.wikipedia.org/wiki/Harris%E2%80%93Benedict_equation

| Param | Type | Description | | --- | --- | --- | | gender | Gender | 'male' or 'female'. | | age | number | Age between 18 and 120. | | weight | number | Weight between 15kg and 635kg. | | height | number | Height of a person. |

dietary~tdee(gender, age, weight, height, activity, imperial, equation) ⇒ number

Calculates total daily energy expenditure (TDEE); the number of calories our body burns daily to perform its bodily functions based on activity level.

Kind: inner method of dietary
Returns: number - BMR.

| Param | Type | Description | | --- | --- | --- | | gender | Gender | 'male' or 'female'. | | age | number | Age between 18 and 120. | | weight | number | Weight between 15kg and 635kg. | | height | number | Height of a person. | | activity | ActivityLevel | Activity level. | | imperial | boolean | Flag to use imperial (lb and inch). Default to use metric (kg and cm). | | equation | BmrEquation | Equation to use ('harrisBenedict', 'rozaAndShizgal', or 'mifflin'). Default to 'mifflin'. |

dietary~amdr(gender, age, weight, height, activity, imperial, equation) ⇒ number

Calculates acceptable macronutrient range (AMDR).

Kind: inner method of dietary
Returns: number - BMR.

| Param | Type | Description | | --- | --- | --- | | gender | Gender | 'male' or 'female'. | | age | number | Age between 18 and 120. | | weight | number | Weight between 15kg and 635kg. | | height | number | Height of a person. | | activity | ActivityLevel | Activity level. | | imperial | boolean | Flag to use imperial (lb and inch). Default to use metric (kg and cm). | | equation | BmrEquation | Equation to use ('harrisBenedict', 'rozaAndShizgal', or 'mifflin'). Default to 'mifflin'. |

sports

sports~oneRm(reps, weight, formula) ⇒ number

Calculates one-repetition maximum (1RM) using various formula.

Kind: inner method of sports
Returns: number - One rep max.

| Param | Type | Description | | --- | --- | --- | | reps | number | Number of repetition of a given weight. | | weight | number | Weight being lifted for a given reps. | | formula | OneRmFormula | Formula to use. |

sports~hrMax(age, formula) ⇒ number

Calculates maximum heart rate (HR) of a given age and formula.

Kind: inner method of sports
Returns: number - HRmax in BPM (beats per minute).

| Param | Type | Description | | --- | --- | --- | | age | number | Person age. | | formula | HRMaxFormula | Formula to use. |

util

util~cmToInch(cm) ⇒ number

Converts cm to inch.

Kind: inner method of util
Returns: number - Length in inch.

| Param | Type | Description | | --- | --- | --- | | cm | number | Length in cm. |

util~inchToCm(inch) ⇒ number

Converts inch to cm.

Kind: inner method of util
Returns: number - Length in cm.

| Param | Type | Description | | --- | --- | --- | | inch | number | Length in inch. |

util~lbToKg(lb) ⇒ number

Converts lb to kg.

Kind: inner method of util
Returns: number - Weight in kg.

| Param | Type | Description | | --- | --- | --- | | lb | number | Weight in lb. |

util~kgToLb(kg) ⇒ number

Converts kg to lb.

Kind: inner method of util
Returns: number - Weight in lb.

| Param | Type | Description | | --- | --- | --- | | kg | number | Weight in kg. |