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

jp-healthmeasurements

v1.3.8

Published

Calculates an Individuals BMI and other health measurements automatically so you dont have to handle the math in your code

Downloads

10

Readme

jp-healthmeasurements - Calculating Health Measurements Made Easy

Are you building a health/fitness application and don't feel like doing all the calculations for things like BMI, Body Fat Percentage, Daliy Calories Needed, and more?

jp-healthmeasurements is compatible with both the metric and imperial measurement systems and allows you to calculate some of the most common health/fitness related measurements without having to do any of the Math yourself

Health Calculations

  • bodyMassIndex
  • waistToHeightRatio
  • caloriesNeeded
  • bodyFatPct
  • leanBodyFat
  • dailyMacros

Utility Functions for Converting Units

  • cmToInches
  • inchesToCentimeters
  • poundsToKilos
  • kilosToPounds
  • caloriesToGrams

Installation

npm i jp-healthmeasurements

Import into project

import { bodyMassIndex, waistToHeightRatio, caloriesNeeded, bodyFatPct, leanBodyMass, dailyMacros, } from 'jp-healthmeasurements';

How It Works

bodyMassIndex

bodyMassIndex(weight: number, height: number, imperial?: boolean): number

  • weight is specified as kgs || lbs
  • height is specified as cms || inches
  • if using the metric system imperial is not needed or can be false
  • if using the imperial system imperial must be true

Metric

bodyMassIndex(83.9146, 165.1); returns 30.79

bodyMassIndex(83.9146, 165.1, false); returns 30.79

Imperial

bodyMassIndex(185, 65, true); returns 30.78

** Due to some approximations on the agreed upon formulas the results may vary between systems. The differences are statistically insignificant and can be ignored. **

waistToHeightRatio

waistToHeightRatio(waist: number, height: number, imperial?: boolean): number

  • waist is specified as cms || inches
  • height is specified as cms || inches
  • if using the metric system imperial is not needed or can be false
  • if using the imperial system imperial must be true

Metric

waistToHeightRatio(91.44, 165.1); returns 55.38

Imperial

waistToHeightRatio(36, 65, true); returns 55.38

caloriesNeeded

caloriesNeeded(weight: number, height: number, age:number, male: boolean, imperial?: boolean): number

  • weight is specified as kgs || lbs
  • height is specified as cms || inches
  • age is specified in years
  • male is a boolean: true or false depending on gender
  • if using the metric system imperial is not needed or can be false
  • if using the imperial system imperial must be true

Metric

caloriesNeeded(83.9146, 165.1, 30, true); returns 1726.02

Imperial

caloriesNeeded(185, 65, 30, true, true); returns 1725.88

bodyFatPct

bodyFatPct(bmi: number, age:number, male: boolean): number

  • bmi is a number returned from the bodyMassIndex method above
  • age is a number specified in years
  • male is a boolean: true or false depending on gender

bodyFatPct(30.78, age:30, male: true) returns 27.64

leanBodyMass

leanBodyMass(weight: number, height:number, male: boolean, imperial?: boolean): number

  • weight is specified as kgs || lbs
  • height is specified as cms || inches
  • male is a boolean: true or false depending on gender
  • if using the metric system imperial is not needed or can be false
  • if using the imperial system imperial must be true

Metric

leanBodyMass(83.9146, 165.1, true); returns 59.03

Imperial

leanBodyMass(185, 65, true, true); returns 59.03

dailyMacros

dailyMacros(calories: number, fat: number = .20, carbs: number = .55, protein: number = .25): Macros

** Returns a 'Macros' object **

Macros { fCal: number, fGram: number, cCal: number, cGram: number, pCal: number, pGram: number }

** Unless otherwise specified the macro values are predefined based on CDC recommendations **

  • fat = 20%
  • carbs = 55%
  • protein = 25%

Calculate the calories parameter from the caloriesNeeded method above

dailyMacros(1726.02) returns

{ "fCal": 345.2, "fGram": 38.36, "cCal": 949.31, "cGram": 237.33, "pCal": 431.5, "pGram": 107.88 }

dailyMacros(1726.02, .25, .45, .30) returns

{ "fCal": 431.5, "fGram": 47.94, "cCal": 776.71, "cGram": 194.18, "pCal": 517.81, "pGram": 129.45 }

Project is free to use and improvements are welcome. Source code found at https://github.com/JustinPaoletta/health-measurements