hevy-shared 1.0.647 → 1.0.648
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/index.d.ts +6 -0
- package/built/muscleSplits.d.ts +12 -18
- package/built/muscleSplits.js +16 -45
- package/package.json +1 -1
- package/built/tests/muscleSplit.test.d.ts +0 -1
- package/built/tests/muscleSplit.test.js +0 -153
package/built/index.d.ts
CHANGED
|
@@ -772,6 +772,10 @@ export interface WorkoutVideo {
|
|
|
772
772
|
thumbnail_url: string;
|
|
773
773
|
}
|
|
774
774
|
export type WorkoutMedia = WorkoutImage | WorkoutVideo;
|
|
775
|
+
export type PreviewWorkoutLike = {
|
|
776
|
+
username: string;
|
|
777
|
+
profile_pic: string;
|
|
778
|
+
};
|
|
775
779
|
export interface Workout {
|
|
776
780
|
id: string;
|
|
777
781
|
short_id: string | null;
|
|
@@ -779,7 +783,9 @@ export interface Workout {
|
|
|
779
783
|
name: string;
|
|
780
784
|
description?: string;
|
|
781
785
|
like_count: number;
|
|
786
|
+
/** @deprecated 2.3.4 */
|
|
782
787
|
like_images: string[];
|
|
788
|
+
preview_workout_likes: PreviewWorkoutLike[];
|
|
783
789
|
comment_count: number;
|
|
784
790
|
comments: WorkoutComment[];
|
|
785
791
|
/** @deprecated 1.28.13 */
|
package/built/muscleSplits.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MuscleGroup, SetType
|
|
1
|
+
import { MuscleGroup, SetType } from '.';
|
|
2
2
|
interface SetCountableSet {
|
|
3
3
|
indicator: SetType;
|
|
4
4
|
}
|
|
@@ -7,13 +7,18 @@ interface SetCountableExercise {
|
|
|
7
7
|
other_muscles: MuscleGroup[];
|
|
8
8
|
sets: SetCountableSet[];
|
|
9
9
|
}
|
|
10
|
-
|
|
10
|
+
interface SetCountableWorkoutOrRoutine {
|
|
11
11
|
exercises: SetCountableExercise[];
|
|
12
12
|
}
|
|
13
|
-
export declare const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
export declare const getSetContributionsForMuscleGroups: (muscle_group: MuscleGroup, other_muscles: MuscleGroup[]) => {
|
|
14
|
+
core: number;
|
|
15
|
+
shoulders: number;
|
|
16
|
+
arms: number;
|
|
17
|
+
legs: number;
|
|
18
|
+
back: number;
|
|
19
|
+
chest: number;
|
|
20
|
+
};
|
|
21
|
+
export declare const calculateSimplifiedMuscleSplit: (workoutsOrRoutines: SetCountableWorkoutOrRoutine[], shouldIncludeWarmupSets: boolean) => {
|
|
17
22
|
core: number;
|
|
18
23
|
shoulders: number;
|
|
19
24
|
arms: number;
|
|
@@ -21,16 +26,5 @@ export declare const calculateSetContributionsForSimplifiedMuscleGroups: ({ musc
|
|
|
21
26
|
back: number;
|
|
22
27
|
chest: number;
|
|
23
28
|
};
|
|
24
|
-
export declare const
|
|
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>;
|
|
29
|
+
export declare const getSetCountPerMuscleGroups: (workout: SetCountableWorkoutOrRoutine, shouldIncludeWarmupSets: boolean) => Partial<{ [key in MuscleGroup]: number; }>;
|
|
36
30
|
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.getSetCountPerMuscleGroups = exports.calculateSimplifiedMuscleSplit = exports.getSetContributionsForMuscleGroups = void 0;
|
|
7
7
|
const intersection_1 = __importDefault(require("lodash/intersection"));
|
|
8
8
|
const _1 = require(".");
|
|
9
|
-
const
|
|
9
|
+
const getSetContributionsForMuscleGroups = (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 calculateSetContributionsForSimplifiedMuscleGroups = ({ muscle_group, othe
|
|
|
28
28
|
chest: getContribution(_1.chestMuscles),
|
|
29
29
|
};
|
|
30
30
|
};
|
|
31
|
-
exports.
|
|
32
|
-
const calculateSimplifiedMuscleSplit = (
|
|
31
|
+
exports.getSetContributionsForMuscleGroups = getSetContributionsForMuscleGroups;
|
|
32
|
+
const calculateSimplifiedMuscleSplit = (workoutsOrRoutines, shouldIncludeWarmupSets) => {
|
|
33
33
|
const totals = {
|
|
34
34
|
core: 0,
|
|
35
35
|
shoulders: 0,
|
|
@@ -40,14 +40,11 @@ const calculateSimplifiedMuscleSplit = ({ workoutsOrRoutines, includeWarmupSets,
|
|
|
40
40
|
};
|
|
41
41
|
for (const workoutOrRoutine of workoutsOrRoutines) {
|
|
42
42
|
for (const exercise of workoutOrRoutine.exercises) {
|
|
43
|
-
const trimmedSets =
|
|
43
|
+
const trimmedSets = shouldIncludeWarmupSets
|
|
44
44
|
? exercise.sets
|
|
45
45
|
: exercise.sets.filter((s) => s.indicator !== 'warmup');
|
|
46
46
|
const setCount = trimmedSets.length;
|
|
47
|
-
const contributions = (0, exports.
|
|
48
|
-
muscle_group: exercise.muscle_group,
|
|
49
|
-
other_muscles: exercise.other_muscles,
|
|
50
|
-
});
|
|
47
|
+
const contributions = (0, exports.getSetContributionsForMuscleGroups)(exercise.muscle_group, exercise.other_muscles);
|
|
51
48
|
totals.core += contributions.core * setCount;
|
|
52
49
|
totals.shoulders += contributions.shoulders * setCount;
|
|
53
50
|
totals.arms += contributions.arms * setCount;
|
|
@@ -59,42 +56,16 @@ const calculateSimplifiedMuscleSplit = ({ workoutsOrRoutines, includeWarmupSets,
|
|
|
59
56
|
return totals;
|
|
60
57
|
};
|
|
61
58
|
exports.calculateSimplifiedMuscleSplit = calculateSimplifiedMuscleSplit;
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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;
|
|
59
|
+
const getSetCountPerMuscleGroups = (workout, shouldIncludeWarmupSets) => {
|
|
60
|
+
return workout.exercises.reduce((acc, e) => {
|
|
61
|
+
const trimmedSets = shouldIncludeWarmupSets
|
|
62
|
+
? e.sets
|
|
63
|
+
: e.sets.filter((s) => s.indicator !== 'warmup');
|
|
64
|
+
acc[e.muscle_group] = (acc[e.muscle_group] || 0) + trimmedSets.length;
|
|
65
|
+
e.other_muscles.forEach((muscle) => {
|
|
66
|
+
acc[muscle] = (acc[muscle] || 0) + trimmedSets.length / 2;
|
|
67
|
+
});
|
|
81
68
|
return acc;
|
|
82
69
|
}, {});
|
|
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;
|
|
99
70
|
};
|
|
100
|
-
exports.
|
|
71
|
+
exports.getSetCountPerMuscleGroups = getSetCountPerMuscleGroups;
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,153 +0,0 @@
|
|
|
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
|
-
});
|