UNPKG

wilks

Version:

Calculate wilks score, dots, one rep max and more. Wilks formula and Dots are primarily used in powerlifting contests to identify the best lifter across different weight classes.

53 lines 2.38 kB
import { coefficients } from "./constants.js"; import { calculateCoefficient, convertWeight, roundToDecimal, validateCompetition, validateInput } from "./helpers.js"; const getTotal = (input) => { if ("total" in input) return input.total; return Object.values(input).reduce((a, b) => a + b, 0); }; export function wilks(input) { validateInput(input); const { gender, bodyweight, unit, ...rest } = input; const coefficient = calculateCoefficient({ gender, bodyweight, unit }, "wilks"); const total = convertWeight(getTotal(rest), unit); const score = total * (500 / coefficient); return roundToDecimal(score, 2); } export function wilks2020(input) { validateInput(input); const { gender, bodyweight, unit, ...rest } = input; const coefficient = calculateCoefficient({ gender, bodyweight, unit }, "wilks2020"); const total = convertWeight(getTotal(rest), unit); const score = total * (600 / coefficient); return roundToDecimal(score, 2); } export function dots(input) { validateInput(input); const { gender, bodyweight, unit, ...rest } = input; const coefficient = calculateCoefficient({ gender, bodyweight, unit }, "dots"); const total = convertWeight(getTotal(rest), unit); const score = total * (500 / coefficient); return roundToDecimal(score, 2); } export function ipf(input, competition) { validateInput(input); validateCompetition(competition); const { gender, bodyweight, unit, ...rest } = input; const total = convertWeight(getTotal(rest), unit); const bw = convertWeight(bodyweight, unit); const lgbw = Math.log(bw); const coefficient = coefficients.ipf[gender][competition]; const score = 500 + 100 * ((total - (coefficient[0] * lgbw - coefficient[1]))) / (coefficient[2] * lgbw - coefficient[3]); return roundToDecimal(score, 2); } export function ipfgl(input, competition) { validateInput(input); validateCompetition(competition); const { gender, bodyweight, unit, ...rest } = input; const total = convertWeight(getTotal(rest), unit); const bw = convertWeight(bodyweight, unit); const coefficient = coefficients.ipfgl[gender][competition]; const score = total * (100 / (coefficient[0] - coefficient[1] * Math.pow(Math.E, (-coefficient[2] * bw)))); return roundToDecimal(score, 2); } //# sourceMappingURL=index.js.map