@plus45/types 1.1.37 → 1.1.39
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/index.ts +6 -1
- package/package.json +1 -1
- package/types/generics/week_layout.ts +53 -0
- package/types/schedule/schedule.ts +3 -1
package/index.ts
CHANGED
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
WeightUnits
|
|
10
10
|
} from "./types/exercise/exercise_units";
|
|
11
11
|
import { Workout } from "./types/workout/workout";
|
|
12
|
-
import { Schedule } from "./types/schedule/schedule";
|
|
12
|
+
import { AssignedSchedule, Schedule } from "./types/schedule/schedule";
|
|
13
13
|
import { ScheduleDay } from "./types/schedule/schedule_days";
|
|
14
14
|
import { ScheduleRecurrence } from "./types/schedule/schedule_recurrence";
|
|
15
15
|
import { UserSessionInfo } from "./types/user/session_info";
|
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
CompletedExercise,
|
|
18
18
|
WorkoutExecution
|
|
19
19
|
} from "./types/workout/workout_execution";
|
|
20
|
+
import { WeekLayout } from "./types/generics/week_layout";
|
|
20
21
|
|
|
21
22
|
export {
|
|
22
23
|
// User Type Structures
|
|
@@ -34,6 +35,10 @@ export {
|
|
|
34
35
|
|
|
35
36
|
// Schedule Type Structures
|
|
36
37
|
type Schedule,
|
|
38
|
+
type AssignedSchedule,
|
|
39
|
+
|
|
40
|
+
// Generics
|
|
41
|
+
type WeekLayout,
|
|
37
42
|
|
|
38
43
|
// Enums
|
|
39
44
|
ExerciseType,
|
package/package.json
CHANGED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export class WeekLayout<T> {
|
|
2
|
+
Sunday: Array<T>;
|
|
3
|
+
Monday: Array<T>;
|
|
4
|
+
Tuesday: Array<T>;
|
|
5
|
+
Wednesday: Array<T>;
|
|
6
|
+
Thursday: Array<T>;
|
|
7
|
+
Friday: Array<T>;
|
|
8
|
+
Saturday: Array<T>;
|
|
9
|
+
|
|
10
|
+
constructor(
|
|
11
|
+
Sunday?: Array<T>,
|
|
12
|
+
Monday?: Array<T>,
|
|
13
|
+
Tuesday?: Array<T>,
|
|
14
|
+
Wednesday?: Array<T>,
|
|
15
|
+
Thursday?: Array<T>,
|
|
16
|
+
Friday?: Array<T>,
|
|
17
|
+
Saturday?: Array<T>
|
|
18
|
+
) {
|
|
19
|
+
this.Sunday = Sunday ?? [];
|
|
20
|
+
this.Monday = Monday ?? [];
|
|
21
|
+
this.Tuesday = Tuesday ?? [];
|
|
22
|
+
this.Wednesday = Wednesday ?? [];
|
|
23
|
+
this.Thursday = Thursday ?? [];
|
|
24
|
+
this.Friday = Friday ?? [];
|
|
25
|
+
this.Saturday = Saturday ?? [];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
private getDayFromIndex = [
|
|
29
|
+
"Sunday",
|
|
30
|
+
"Monday",
|
|
31
|
+
"Tuesday",
|
|
32
|
+
"Wednesday",
|
|
33
|
+
"Thursday",
|
|
34
|
+
"Friday",
|
|
35
|
+
"Saturday"
|
|
36
|
+
];
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* 0 = Sunday, 6 = Saturday
|
|
40
|
+
*/
|
|
41
|
+
public setDay(index: number, value: T[]) {
|
|
42
|
+
const day = this.getDayFromIndex[index] as keyof WeekLayout<T>;
|
|
43
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
44
|
+
(this as any)[day] = value;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
public addToDay(index: number, value: T) {
|
|
48
|
+
const day = this.getDayFromIndex[index] as keyof WeekLayout<T>;
|
|
49
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
50
|
+
const toAddTo = (this as any)[day] as T[];
|
|
51
|
+
toAddTo.push(value);
|
|
52
|
+
}
|
|
53
|
+
}
|