@lukaswhite/bmr

1.1.0 • Public • Published

BMR

A JavaScript library for calculating BMR (basal metabolic rate).

Supported formulae:

  • Mifflin St Jeor.
  • Harris Benedict
  • Harris Benedict (revised)
  • Schofield
  • Katch McArdle

Basic Usage

Import the required classes:

import { BMR, Data } from '@lukaswhite/bmr'

Create an instance of Data, and supply the necessary information:

let data = new Data( )
data.setGender( Data.FEMALE )
    .setAge( 45 )
    .setHeight( 165 )
    .setWeight( 60 )

The height and weight should be in centimetres and kilogrammes respectively

Note that rather than set the age, you can set the date of birth instead:

data.setDateOfBirth( new Date( 1980, 6, 3 ) )

Create an instance of the BMR class:

const bmr = new BMR( BMR.MIFFLIN_ST_JEOR )

Finally, run the calculation:

console.log( bmr.calculate( data ) ) // outputs 1245

Mifflin St Jeor

const bmr = new BMR( BMR.MIFFLIN_ST_JEOR )

This is actually the default formula, so you can simply do this:

const bmr = new BMR( )

The formula requires the gender, age, height and weight.

let data = new Data( )
data.setGender( Data.FEMALE )
    .setAge( 45 )
    .setHeight( 165 )
    .setWeight( 60 )

Harris Benedict

const bmr = new BMR( BMR.HARRIS_BENEDICT )

The formula requires the gender, age, height and weight.

let data = new Data( )
data.setGender( Data.FEMALE )
    .setAge( 45 )
    .setHeight( 165 )
    .setWeight( 60 )

Harris Benedict (Revised)

const bmr = new BMR( BMR.HARRIS_BENEDICT )

The formula requires the gender, age, height and weight.

let data = new Data( )
data.setGender( Data.FEMALE )
    .setAge( 45 )
    .setHeight( 165 )
    .setWeight( 60 )

Schofield

const bmr = new BMR( BMR.SCHOFIELD )

The formula requires the gender, age, weight.

let data = new Data( )
data.setGender( Data.FEMALE )
    .setAge( 45 )
    .setWeight( 60 )

Katch McArdle

const bmr = new BMR( BMR.KATCH_MCARDLE )

The formula requires either the lean body mass, or the weight and body fat percentage

let data = new Data( )
data.setGender( Data.FEMALE )
    .setLeanBodyMass( 50 )

Or

let data = new Data( )
data.setGender( Data.FEMALE )
    .setWeight( 60 )
    .setBodyFat( 17 )

Errors

If you fail to provide all of the required information, the calculator will throw an instance of MissingInformationError.

Upon instantiation, if you supply an invalid formula, it will throw an instance of InvalidFormulaError. However, this is easily avoided by simply using the constants, as per the documentation above.

Readme

Keywords

none

Package Sidebar

Install

npm i @lukaswhite/bmr

Weekly Downloads

0

Version

1.1.0

License

MIT

Unpacked Size

38.3 kB

Total Files

13

Last publish

Collaborators

  • lukaswhite