ski-din-calculator
Version:
Calculate a skier's DIN binding release value based on height, weight, age, skill level, and boot sole length
60 lines (59 loc) • 1.72 kB
JavaScript
;
// Utility functions for the ski DIN calculator package
Object.defineProperty(exports, "__esModule", { value: true });
exports.convertLbsToKg = convertLbsToKg;
exports.convertInchesToCm = convertInchesToCm;
exports.convertCmToInches = convertCmToInches;
exports.convertKgToLbs = convertKgToLbs;
/**
* Converts weight from pounds to kilograms.
* @param pounds - Weight in pounds
* @returns Weight in kilograms (rounded to 2 decimal places)
* @example
* ```typescript
* convertLbsToKg(150) // returns 68.04
* ```
*/
function convertLbsToKg(pounds) {
const KG_PER_LB = 0.45359237;
return Math.round(pounds * KG_PER_LB * 100) / 100;
}
/**
* Converts height from inches to centimeters.
* @param inches - Height in inches
* @returns Height in centimeters (rounded to 2 decimal places)
* @example
* ```typescript
* convertInchesToCm(70) // returns 177.8
* ```
*/
function convertInchesToCm(inches) {
const CM_PER_INCH = 2.54;
return Math.round(inches * CM_PER_INCH * 100) / 100;
}
/**
* Converts height from centimeters to inches.
* @param cm - Height in centimeters
* @returns Height in inches (rounded to 2 decimal places)
* @example
* ```typescript
* convertCmToInches(178) // returns 70.08
* ```
*/
function convertCmToInches(cm) {
const INCHES_PER_CM = 0.393701;
return Math.round(cm * INCHES_PER_CM * 100) / 100;
}
/**
* Converts weight from kilograms to pounds.
* @param kg - Weight in kilograms
* @returns Weight in pounds (rounded to 2 decimal places)
* @example
* ```typescript
* convertKgToLbs(68) // returns 149.91
* ```
*/
function convertKgToLbs(kg) {
const LBS_PER_KG = 2.20462;
return Math.round(kg * LBS_PER_KG * 100) / 100;
}