hevy-shared 1.0.632 → 1.0.633

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.
@@ -1,15 +1,24 @@
1
1
  import { MuscleGroup, SetType } from '.';
2
+ interface SetCountableSet {
3
+ indicator: SetType;
4
+ }
2
5
  interface SetCountableExercise {
3
6
  muscle_group: MuscleGroup;
4
7
  other_muscles: MuscleGroup[];
5
- sets: {
6
- indicator: SetType;
7
- }[];
8
+ sets: SetCountableSet[];
8
9
  }
9
10
  interface SetCountableWorkoutOrRoutine {
10
11
  exercises: SetCountableExercise[];
11
12
  }
12
- export declare const setCountPerSimplifiedMuscleGroups: (workoutsOrRoutines: SetCountableWorkoutOrRoutine[], shouldIncludeWarmupSets: boolean) => {
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) => {
13
22
  core: number;
14
23
  shoulders: number;
15
24
  arms: number;
@@ -3,52 +3,59 @@ 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.getSetCountPerMuscleGroups = exports.setCountPerSimplifiedMuscleGroups = void 0;
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 setCountPerSimplifiedMuscleGroups = (workoutsOrRoutines, shouldIncludeWarmupSets) => {
10
- let core = 0;
11
- let shoulders = 0;
12
- let arms = 0;
13
- let legs = 0;
14
- let back = 0;
15
- let chest = 0;
16
- const muscleGroupValueIncrement = (e, mg) => {
17
- let increment = 0;
18
- const trimmedSets = shouldIncludeWarmupSets
19
- ? e.sets
20
- : e.sets.filter((s) => s.indicator !== 'warmup');
21
- if (mg.includes(e.muscle_group)) {
22
- increment += trimmedSets.length;
9
+ const getSetContributionsForMuscleGroups = (muscle_group, other_muscles) => {
10
+ const getContribution = (mg) => {
11
+ if (mg.includes(muscle_group)) {
12
+ return 1;
23
13
  }
24
- else if ((0, intersection_1.default)(mg, e.other_muscles).length) {
25
- increment += trimmedSets.length / 2;
14
+ else if ((0, intersection_1.default)(mg, other_muscles).length) {
15
+ return 0.5;
26
16
  }
27
- else if (e.muscle_group === 'full_body') {
28
- increment += trimmedSets.length / 6;
17
+ else if (muscle_group === 'full_body') {
18
+ return 1 / 6;
29
19
  }
30
- return increment;
20
+ return 0;
21
+ };
22
+ return {
23
+ core: getContribution(_1.coreMuscles),
24
+ shoulders: getContribution(_1.shoulderMuscles),
25
+ arms: getContribution(_1.armMuscles),
26
+ legs: getContribution(_1.legMuscles),
27
+ back: getContribution(_1.backMuscles),
28
+ chest: getContribution(_1.chestMuscles),
29
+ };
30
+ };
31
+ exports.getSetContributionsForMuscleGroups = getSetContributionsForMuscleGroups;
32
+ const calculateSimplifiedMuscleSplit = (workoutsOrRoutines, shouldIncludeWarmupSets) => {
33
+ const totals = {
34
+ core: 0,
35
+ shoulders: 0,
36
+ arms: 0,
37
+ legs: 0,
38
+ back: 0,
39
+ chest: 0,
31
40
  };
32
41
  for (const workoutOrRoutine of workoutsOrRoutines) {
33
42
  for (const exercise of workoutOrRoutine.exercises) {
34
- core += muscleGroupValueIncrement(exercise, _1.coreMuscles);
35
- shoulders += muscleGroupValueIncrement(exercise, _1.shoulderMuscles);
36
- arms += muscleGroupValueIncrement(exercise, _1.armMuscles);
37
- legs += muscleGroupValueIncrement(exercise, _1.legMuscles);
38
- back += muscleGroupValueIncrement(exercise, _1.backMuscles);
39
- chest += muscleGroupValueIncrement(exercise, _1.chestMuscles);
43
+ const trimmedSets = shouldIncludeWarmupSets
44
+ ? exercise.sets
45
+ : exercise.sets.filter((s) => s.indicator !== 'warmup');
46
+ const setCount = trimmedSets.length;
47
+ const contributions = (0, exports.getSetContributionsForMuscleGroups)(exercise.muscle_group, exercise.other_muscles);
48
+ totals.core += contributions.core * setCount;
49
+ totals.shoulders += contributions.shoulders * setCount;
50
+ totals.arms += contributions.arms * setCount;
51
+ totals.legs += contributions.legs * setCount;
52
+ totals.back += contributions.back * setCount;
53
+ totals.chest += contributions.chest * setCount;
40
54
  }
41
55
  }
42
- return {
43
- core,
44
- shoulders,
45
- arms,
46
- legs,
47
- back,
48
- chest,
49
- };
56
+ return totals;
50
57
  };
51
- exports.setCountPerSimplifiedMuscleGroups = setCountPerSimplifiedMuscleGroups;
58
+ exports.calculateSimplifiedMuscleSplit = calculateSimplifiedMuscleSplit;
52
59
  const getSetCountPerMuscleGroups = (workout, shouldIncludeWarmupSets) => {
53
60
  return workout.exercises.reduce((acc, e) => {
54
61
  const trimmedSets = shouldIncludeWarmupSets
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hevy-shared",
3
- "version": "1.0.632",
3
+ "version": "1.0.633",
4
4
  "description": "",
5
5
  "main": "built/index.js",
6
6
  "types": "built/index.d.ts",