@utiliread/primitives 1.0.0-50 → 1.0.0-53
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/dist/index.d.ts +81 -90
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -23
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7 -22
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/repository-utils.ts +10 -0
- package/src/repository.ts +24 -24
- package/src/step.ts +4 -4
- package/src/time-or-rule.ts +3 -3
- package/.parcel-cache/05bceb1debb074ab +0 -0
- package/.parcel-cache/98c3d22f150231c4 +0 -0
- package/.parcel-cache/a94329c46f41e756 +0 -0
- package/.parcel-cache/b72f446afb579f45 +0 -0
- package/.parcel-cache/d9963624c0099aed.txt +0 -12308
- package/.parcel-cache/data.mdb +0 -0
- package/.parcel-cache/lock.mdb +0 -0
package/src/repository.ts
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
// This is clearly not correct but it provides some amazing type safety
|
|
2
|
-
export type Repository = "some/repo";
|
|
3
|
-
|
|
4
|
-
export function Repository(repo: string): Repository;
|
|
5
|
-
export function Repository(team: string, name: string): Repository;
|
|
6
|
-
export function Repository(repoOrTeam: string, name?: string): Repository {
|
|
7
|
-
if (name) {
|
|
8
|
-
return <Repository>`${repoOrTeam}/${name}`;
|
|
9
|
-
} else if (repoOrTeam.indexOf("/") > 0) {
|
|
10
|
-
return <Repository>repoOrTeam;
|
|
11
|
-
} else {
|
|
12
|
-
throw new TypeError("Invalid repository format");
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export namespace Repository {
|
|
17
|
-
export function split(repo: Repository) {
|
|
18
|
-
const parts = repo.split("/");
|
|
19
|
-
return {
|
|
20
|
-
team: parts[0],
|
|
21
|
-
name: parts[1],
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
}
|
|
1
|
+
// This is clearly not correct but it provides some amazing type safety
|
|
2
|
+
export type Repository = "some/repo";
|
|
3
|
+
|
|
4
|
+
export function Repository(repo: string): Repository;
|
|
5
|
+
export function Repository(team: string, name: string): Repository;
|
|
6
|
+
export function Repository(repoOrTeam: string, name?: string): Repository {
|
|
7
|
+
if (name) {
|
|
8
|
+
return <Repository>`${repoOrTeam}/${name}`;
|
|
9
|
+
} else if (repoOrTeam.indexOf("/") > 0) {
|
|
10
|
+
return <Repository>repoOrTeam;
|
|
11
|
+
} else {
|
|
12
|
+
throw new TypeError("Invalid repository format");
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export namespace Repository {
|
|
17
|
+
export function split(repo: Repository) {
|
|
18
|
+
const parts = repo.split("/");
|
|
19
|
+
return {
|
|
20
|
+
team: parts[0],
|
|
21
|
+
name: parts[1],
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
}
|
package/src/step.ts
CHANGED
|
@@ -12,8 +12,8 @@ export enum DayOfWeek {
|
|
|
12
12
|
Sunday = 7,
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
export function startOf(dateTime: DateTime, step: Step, firstDayOfWeek?: DayOfWeek) {
|
|
15
|
+
namespace Step {
|
|
16
|
+
export function startOf(dateTime: DateTime, step: Step, firstDayOfWeek?: DayOfWeek): DateTime {
|
|
17
17
|
if (step === "week") {
|
|
18
18
|
const value = dateTime.startOf("day").set({ weekday: firstDayOfWeek ?? DayOfWeek.Monday });
|
|
19
19
|
return value > dateTime
|
|
@@ -24,7 +24,7 @@ export namespace Step {
|
|
|
24
24
|
return dateTime.startOf(step);
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
-
|
|
27
|
+
|
|
28
28
|
export function asDuration(step: Step, amount = 1): Duration {
|
|
29
29
|
switch (step) {
|
|
30
30
|
case "hour": return Duration.fromObject({ hours: amount });
|
|
@@ -34,4 +34,4 @@ export namespace Step {
|
|
|
34
34
|
case "year": return Duration.fromObject({ years: amount });
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
-
}
|
|
37
|
+
}
|
package/src/time-or-rule.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { DateTime } from "luxon";
|
|
|
2
2
|
|
|
3
3
|
export type TimeOrRule = Date | DateTime | string;
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
namespace TimeOrRule {
|
|
6
6
|
export function isTime(input: TimeOrRule): input is Date | DateTime {
|
|
7
7
|
return typeof input !== "string";
|
|
8
8
|
}
|
|
@@ -10,8 +10,8 @@ export namespace TimeOrRule {
|
|
|
10
10
|
export function isRule(input: TimeOrRule): input is string {
|
|
11
11
|
return typeof input === "string";
|
|
12
12
|
}
|
|
13
|
-
|
|
13
|
+
|
|
14
14
|
export function asJSON(input: TimeOrRule) {
|
|
15
15
|
return isRule(input) ? input : input.toJSON();
|
|
16
16
|
}
|
|
17
|
-
}
|
|
17
|
+
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|