@nathaliem/one-rep-max
Version:
One Rep Max calculations
75 lines (72 loc) • 1.9 kB
JavaScript
var __defProp = Object.defineProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
// src/formulas.ts
var formulas_exports = {};
__export(formulas_exports, {
brzycki: () => brzycki,
epley: () => epley,
landers: () => landers,
lombardi: () => lombardi,
mayhew: () => mayhew,
oconner: () => oconner,
wathan: () => wathan
});
function epley(weight, reps) {
return weight * (1 + reps / 30);
}
function brzycki(weight, reps) {
return weight * (36 / (37 - reps));
}
function lombardi(weight, reps) {
return weight * Math.pow(reps, 0.1);
}
function mayhew(weight, reps) {
return 100 * weight / (52.2 + 41.9 * Math.exp(-0.055 * reps));
}
function oconner(weight, reps) {
return weight * (1 + 0.025 * reps);
}
function wathan(weight, reps) {
return 100 * weight / (48.8 + 53.8 * Math.exp(-0.075 * reps));
}
function landers(weight, reps) {
return 100 * weight / (101.3 - 2.67123 * reps);
}
// src/index.ts
function getOneRepMax(weight, reps, decimals = 2, formula) {
if (!formula) {
return parseFloat(averageOneRepMax(weight, reps).toFixed(decimals));
}
const fn = formulas_exports[formula];
if (!fn) throw new Error("Unknown formula");
return parseFloat(fn(weight, reps).toFixed(decimals));
}
function averageOneRepMax(weight, reps) {
const formulas = [
"epley",
"brzycki",
"lombardi",
"mayhew",
"oconner",
"wathan",
"landers"
];
const estimates = formulas.map((f) => getOneRepMax(weight, reps, 2, f));
return estimates.reduce((a, b) => a + b, 0) / estimates.length;
}
function getAllFormulas(weight, reps, decimals = 2) {
return Object.fromEntries(
Object.keys(formulas_exports).map((f) => [
f,
+formulas_exports[f](weight, reps).toFixed(decimals)
])
);
}
export {
averageOneRepMax,
getAllFormulas,
getOneRepMax
};