hevy-shared 1.0.659 → 1.0.660
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/built/muscleSplits.d.ts +18 -12
- package/built/muscleSplits.js +45 -16
- package/built/tests/muscleSplit.test.d.ts +1 -0
- package/built/tests/muscleSplit.test.js +153 -0
- package/package.json +1 -1
package/built/muscleSplits.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MuscleGroup, SetType } from '.';
|
|
1
|
+
import { MuscleGroup, SetType, SimplifiedMuscleGroup } from '.';
|
|
2
2
|
interface SetCountableSet {
|
|
3
3
|
indicator: SetType;
|
|
4
4
|
}
|
|
@@ -7,18 +7,13 @@ interface SetCountableExercise {
|
|
|
7
7
|
other_muscles: MuscleGroup[];
|
|
8
8
|
sets: SetCountableSet[];
|
|
9
9
|
}
|
|
10
|
-
interface SetCountableWorkoutOrRoutine {
|
|
10
|
+
export interface SetCountableWorkoutOrRoutine {
|
|
11
11
|
exercises: SetCountableExercise[];
|
|
12
12
|
}
|
|
13
|
-
export declare const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
legs: number;
|
|
18
|
-
back: number;
|
|
19
|
-
chest: number;
|
|
20
|
-
};
|
|
21
|
-
export declare const calculateSimplifiedMuscleSplit: (workoutsOrRoutines: SetCountableWorkoutOrRoutine[], shouldIncludeWarmupSets: boolean) => {
|
|
13
|
+
export declare const calculateSetContributionsForSimplifiedMuscleGroups: ({ muscle_group, other_muscles, }: {
|
|
14
|
+
muscle_group: MuscleGroup;
|
|
15
|
+
other_muscles: MuscleGroup[];
|
|
16
|
+
}) => {
|
|
22
17
|
core: number;
|
|
23
18
|
shoulders: number;
|
|
24
19
|
arms: number;
|
|
@@ -26,5 +21,16 @@ export declare const calculateSimplifiedMuscleSplit: (workoutsOrRoutines: SetCou
|
|
|
26
21
|
back: number;
|
|
27
22
|
chest: number;
|
|
28
23
|
};
|
|
29
|
-
export declare const
|
|
24
|
+
export declare const calculateSimplifiedMuscleSplit: ({ workoutsOrRoutines, includeWarmupSets, }: {
|
|
25
|
+
workoutsOrRoutines: SetCountableWorkoutOrRoutine[];
|
|
26
|
+
includeWarmupSets: boolean;
|
|
27
|
+
}) => Record<SimplifiedMuscleGroup, number>;
|
|
28
|
+
export declare const calculateSetContributionsForMuscleGroups: ({ muscleGroup, otherMuscles, }: {
|
|
29
|
+
muscleGroup: MuscleGroup;
|
|
30
|
+
otherMuscles: MuscleGroup[];
|
|
31
|
+
}) => Record<MuscleGroup, number>;
|
|
32
|
+
export declare const calculateSetCountPerMuscleGroups: ({ workoutsOrRoutines, includeWarmupSets, }: {
|
|
33
|
+
workoutsOrRoutines: SetCountableWorkoutOrRoutine[];
|
|
34
|
+
includeWarmupSets: boolean;
|
|
35
|
+
}) => Record<MuscleGroup, number>;
|
|
30
36
|
export {};
|
package/built/muscleSplits.js
CHANGED
|
@@ -3,10 +3,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.calculateSetCountPerMuscleGroups = exports.calculateSetContributionsForMuscleGroups = exports.calculateSimplifiedMuscleSplit = exports.calculateSetContributionsForSimplifiedMuscleGroups = void 0;
|
|
7
7
|
const intersection_1 = __importDefault(require("lodash/intersection"));
|
|
8
8
|
const _1 = require(".");
|
|
9
|
-
const
|
|
9
|
+
const calculateSetContributionsForSimplifiedMuscleGroups = ({ muscle_group, other_muscles, }) => {
|
|
10
10
|
const getContribution = (mg) => {
|
|
11
11
|
if (mg.includes(muscle_group)) {
|
|
12
12
|
return 1;
|
|
@@ -28,8 +28,8 @@ const getSetContributionsForMuscleGroups = (muscle_group, other_muscles) => {
|
|
|
28
28
|
chest: getContribution(_1.chestMuscles),
|
|
29
29
|
};
|
|
30
30
|
};
|
|
31
|
-
exports.
|
|
32
|
-
const calculateSimplifiedMuscleSplit = (workoutsOrRoutines,
|
|
31
|
+
exports.calculateSetContributionsForSimplifiedMuscleGroups = calculateSetContributionsForSimplifiedMuscleGroups;
|
|
32
|
+
const calculateSimplifiedMuscleSplit = ({ workoutsOrRoutines, includeWarmupSets, }) => {
|
|
33
33
|
const totals = {
|
|
34
34
|
core: 0,
|
|
35
35
|
shoulders: 0,
|
|
@@ -40,11 +40,14 @@ const calculateSimplifiedMuscleSplit = (workoutsOrRoutines, shouldIncludeWarmupS
|
|
|
40
40
|
};
|
|
41
41
|
for (const workoutOrRoutine of workoutsOrRoutines) {
|
|
42
42
|
for (const exercise of workoutOrRoutine.exercises) {
|
|
43
|
-
const trimmedSets =
|
|
43
|
+
const trimmedSets = includeWarmupSets
|
|
44
44
|
? exercise.sets
|
|
45
45
|
: exercise.sets.filter((s) => s.indicator !== 'warmup');
|
|
46
46
|
const setCount = trimmedSets.length;
|
|
47
|
-
const contributions = (0, exports.
|
|
47
|
+
const contributions = (0, exports.calculateSetContributionsForSimplifiedMuscleGroups)({
|
|
48
|
+
muscle_group: exercise.muscle_group,
|
|
49
|
+
other_muscles: exercise.other_muscles,
|
|
50
|
+
});
|
|
48
51
|
totals.core += contributions.core * setCount;
|
|
49
52
|
totals.shoulders += contributions.shoulders * setCount;
|
|
50
53
|
totals.arms += contributions.arms * setCount;
|
|
@@ -56,16 +59,42 @@ const calculateSimplifiedMuscleSplit = (workoutsOrRoutines, shouldIncludeWarmupS
|
|
|
56
59
|
return totals;
|
|
57
60
|
};
|
|
58
61
|
exports.calculateSimplifiedMuscleSplit = calculateSimplifiedMuscleSplit;
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
62
|
+
const calculateSetContributionsForMuscleGroups = ({ muscleGroup, otherMuscles, }) => {
|
|
63
|
+
const getContribution = (mg) => {
|
|
64
|
+
if (mg === muscleGroup) {
|
|
65
|
+
return 1;
|
|
66
|
+
}
|
|
67
|
+
else if (otherMuscles.includes(mg)) {
|
|
68
|
+
return 0.5;
|
|
69
|
+
}
|
|
70
|
+
return 0;
|
|
71
|
+
};
|
|
72
|
+
return _1.muscleGroups.reduce((acc, mg) => {
|
|
73
|
+
acc[mg] = getContribution(mg);
|
|
74
|
+
return acc;
|
|
75
|
+
}, {});
|
|
76
|
+
};
|
|
77
|
+
exports.calculateSetContributionsForMuscleGroups = calculateSetContributionsForMuscleGroups;
|
|
78
|
+
const calculateSetCountPerMuscleGroups = ({ workoutsOrRoutines, includeWarmupSets, }) => {
|
|
79
|
+
const totals = _1.muscleGroups.reduce((acc, muscleGroup) => {
|
|
80
|
+
acc[muscleGroup] = 0;
|
|
68
81
|
return acc;
|
|
69
82
|
}, {});
|
|
83
|
+
for (const workoutOrRoutine of workoutsOrRoutines) {
|
|
84
|
+
for (const exercise of workoutOrRoutine.exercises) {
|
|
85
|
+
const trimmedSets = includeWarmupSets
|
|
86
|
+
? exercise.sets
|
|
87
|
+
: exercise.sets.filter((s) => s.indicator !== 'warmup');
|
|
88
|
+
const setCount = trimmedSets.length;
|
|
89
|
+
const contributions = (0, exports.calculateSetContributionsForMuscleGroups)({
|
|
90
|
+
muscleGroup: exercise.muscle_group,
|
|
91
|
+
otherMuscles: exercise.other_muscles,
|
|
92
|
+
});
|
|
93
|
+
for (const muscleGroup of _1.muscleGroups) {
|
|
94
|
+
totals[muscleGroup] += contributions[muscleGroup] * setCount;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return totals;
|
|
70
99
|
};
|
|
71
|
-
exports.
|
|
100
|
+
exports.calculateSetCountPerMuscleGroups = calculateSetCountPerMuscleGroups;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const muscleSplits_1 = require("../muscleSplits");
|
|
4
|
+
class SetCountableWorkoutOrRoutineBuilder {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.exercises = [];
|
|
7
|
+
}
|
|
8
|
+
addExercise(muscle_group, other_muscles, sets) {
|
|
9
|
+
this.exercises.push({
|
|
10
|
+
muscle_group,
|
|
11
|
+
other_muscles,
|
|
12
|
+
sets: sets.map((indicator) => ({ indicator })),
|
|
13
|
+
});
|
|
14
|
+
return this;
|
|
15
|
+
}
|
|
16
|
+
build() {
|
|
17
|
+
return {
|
|
18
|
+
exercises: this.exercises,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
describe('muscleSplits', () => {
|
|
23
|
+
describe('calculateSetContributionsForSimplifiedMuscleGroups', () => {
|
|
24
|
+
it('should return 1 for the main muscle group', () => {
|
|
25
|
+
const contributions = (0, muscleSplits_1.calculateSetContributionsForSimplifiedMuscleGroups)({
|
|
26
|
+
muscle_group: 'chest',
|
|
27
|
+
other_muscles: [],
|
|
28
|
+
});
|
|
29
|
+
expect(contributions.chest).toBe(1);
|
|
30
|
+
expect(contributions.back).toBe(0);
|
|
31
|
+
expect(contributions.shoulders).toBe(0);
|
|
32
|
+
expect(contributions.arms).toBe(0);
|
|
33
|
+
expect(contributions.legs).toBe(0);
|
|
34
|
+
expect(contributions.core).toBe(0);
|
|
35
|
+
});
|
|
36
|
+
it('should return 0.5 for other muscle groups', () => {
|
|
37
|
+
const contributions = (0, muscleSplits_1.calculateSetContributionsForSimplifiedMuscleGroups)({
|
|
38
|
+
muscle_group: 'shoulders',
|
|
39
|
+
other_muscles: ['triceps'],
|
|
40
|
+
});
|
|
41
|
+
expect(contributions.shoulders).toBe(1);
|
|
42
|
+
expect(contributions.arms).toBe(0.5);
|
|
43
|
+
});
|
|
44
|
+
it('should return 1/6 for full body exercises', () => {
|
|
45
|
+
const contributions = (0, muscleSplits_1.calculateSetContributionsForSimplifiedMuscleGroups)({
|
|
46
|
+
muscle_group: 'full_body',
|
|
47
|
+
other_muscles: [],
|
|
48
|
+
});
|
|
49
|
+
const expected = 1 / 6;
|
|
50
|
+
expect(contributions.chest).toBe(expected);
|
|
51
|
+
expect(contributions.back).toBe(expected);
|
|
52
|
+
expect(contributions.shoulders).toBe(expected);
|
|
53
|
+
expect(contributions.arms).toBe(expected);
|
|
54
|
+
expect(contributions.legs).toBe(expected);
|
|
55
|
+
expect(contributions.core).toBe(expected);
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
describe('calculateSimplifiedMuscleSplit', () => {
|
|
59
|
+
it('should calculate the split correctly', () => {
|
|
60
|
+
const workout = new SetCountableWorkoutOrRoutineBuilder()
|
|
61
|
+
.addExercise('chest', ['triceps'], ['normal', 'normal', 'normal'])
|
|
62
|
+
.addExercise('lats', ['biceps'], ['normal', 'normal'])
|
|
63
|
+
.build();
|
|
64
|
+
const split = (0, muscleSplits_1.calculateSimplifiedMuscleSplit)({
|
|
65
|
+
workoutsOrRoutines: [workout],
|
|
66
|
+
includeWarmupSets: false,
|
|
67
|
+
});
|
|
68
|
+
expect(split.chest).toBe(3);
|
|
69
|
+
expect(split.arms).toBe(3 * 0.5 + 2 * 0.5); // 1.5 from chest day, 1 from back day
|
|
70
|
+
expect(split.back).toBe(2);
|
|
71
|
+
});
|
|
72
|
+
it('should handle warmup sets', () => {
|
|
73
|
+
const workout = new SetCountableWorkoutOrRoutineBuilder()
|
|
74
|
+
.addExercise('chest', ['triceps'], ['warmup', 'normal', 'normal', 'failure'])
|
|
75
|
+
.build();
|
|
76
|
+
const splitWithWarmup = (0, muscleSplits_1.calculateSimplifiedMuscleSplit)({
|
|
77
|
+
workoutsOrRoutines: [workout],
|
|
78
|
+
includeWarmupSets: true,
|
|
79
|
+
});
|
|
80
|
+
expect(splitWithWarmup.chest).toBe(4);
|
|
81
|
+
expect(splitWithWarmup.arms).toBe(4 * 0.5);
|
|
82
|
+
const splitWithoutWarmup = (0, muscleSplits_1.calculateSimplifiedMuscleSplit)({
|
|
83
|
+
workoutsOrRoutines: [workout],
|
|
84
|
+
includeWarmupSets: false,
|
|
85
|
+
});
|
|
86
|
+
expect(splitWithoutWarmup.chest).toBe(3);
|
|
87
|
+
expect(splitWithoutWarmup.arms).toBe(3 * 0.5);
|
|
88
|
+
});
|
|
89
|
+
it('should count a set as 1 for a simplified group even if primary and other muscles are in the same group', () => {
|
|
90
|
+
const workout = new SetCountableWorkoutOrRoutineBuilder()
|
|
91
|
+
.addExercise('quadriceps', ['hamstrings', 'glutes'], // also in legs
|
|
92
|
+
['normal'])
|
|
93
|
+
.build();
|
|
94
|
+
const split = (0, muscleSplits_1.calculateSimplifiedMuscleSplit)({
|
|
95
|
+
workoutsOrRoutines: [workout],
|
|
96
|
+
includeWarmupSets: false,
|
|
97
|
+
});
|
|
98
|
+
expect(split.legs).toBe(1);
|
|
99
|
+
expect(split.chest).toBe(0);
|
|
100
|
+
expect(split.back).toBe(0);
|
|
101
|
+
expect(split.shoulders).toBe(0);
|
|
102
|
+
expect(split.arms).toBe(0);
|
|
103
|
+
expect(split.core).toBe(0);
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
describe('calculateSetContributionsForMuscleGroups', () => {
|
|
107
|
+
it('should return 1 for the main muscle group and 0.5 for others', () => {
|
|
108
|
+
const contributions = (0, muscleSplits_1.calculateSetContributionsForMuscleGroups)({
|
|
109
|
+
muscleGroup: 'chest',
|
|
110
|
+
otherMuscles: ['shoulders', 'triceps'],
|
|
111
|
+
});
|
|
112
|
+
expect(contributions.chest).toBe(1);
|
|
113
|
+
expect(contributions.shoulders).toBe(0.5);
|
|
114
|
+
expect(contributions.triceps).toBe(0.5);
|
|
115
|
+
expect(contributions.lats).toBe(0);
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
describe('calculateSetCountPerMuscleGroups', () => {
|
|
119
|
+
it('should calculate the set count per muscle group', () => {
|
|
120
|
+
const workout = new SetCountableWorkoutOrRoutineBuilder()
|
|
121
|
+
.addExercise('chest', ['shoulders', 'triceps'], ['normal', 'normal', 'normal'])
|
|
122
|
+
.addExercise('lats', ['biceps'], ['normal', 'normal'])
|
|
123
|
+
.build();
|
|
124
|
+
const counts = (0, muscleSplits_1.calculateSetCountPerMuscleGroups)({
|
|
125
|
+
workoutsOrRoutines: [workout],
|
|
126
|
+
includeWarmupSets: false,
|
|
127
|
+
});
|
|
128
|
+
expect(counts.chest).toBe(3);
|
|
129
|
+
expect(counts.shoulders).toBe(3 * 0.5);
|
|
130
|
+
expect(counts.triceps).toBe(3 * 0.5);
|
|
131
|
+
expect(counts.lats).toBe(2);
|
|
132
|
+
expect(counts.biceps).toBe(2 * 0.5);
|
|
133
|
+
expect(counts.abdominals).toBe(0);
|
|
134
|
+
});
|
|
135
|
+
it('should handle warmup sets correctly', () => {
|
|
136
|
+
const workout = new SetCountableWorkoutOrRoutineBuilder()
|
|
137
|
+
.addExercise('chest', ['shoulders', 'triceps'], ['warmup', 'normal', 'normal'])
|
|
138
|
+
.build();
|
|
139
|
+
const countsWithWarmup = (0, muscleSplits_1.calculateSetCountPerMuscleGroups)({
|
|
140
|
+
workoutsOrRoutines: [workout],
|
|
141
|
+
includeWarmupSets: true,
|
|
142
|
+
});
|
|
143
|
+
expect(countsWithWarmup.chest).toBe(3);
|
|
144
|
+
expect(countsWithWarmup.shoulders).toBe(3 * 0.5);
|
|
145
|
+
const countsWithoutWarmup = (0, muscleSplits_1.calculateSetCountPerMuscleGroups)({
|
|
146
|
+
workoutsOrRoutines: [workout],
|
|
147
|
+
includeWarmupSets: false,
|
|
148
|
+
});
|
|
149
|
+
expect(countsWithoutWarmup.chest).toBe(2);
|
|
150
|
+
expect(countsWithoutWarmup.shoulders).toBe(2 * 0.5);
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
});
|