@bgord/tools 1.3.12 → 1.3.14
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/age.vo.js +1 -1
- package/dist/date-range.vo.d.ts +1 -0
- package/dist/date-range.vo.js +4 -1
- package/dist/dll.service.d.ts +2 -2
- package/dist/hour.vo.d.ts +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.js +1 -2
- package/dist/linear-regression.service.d.ts +1 -1
- package/dist/mean.service.d.ts +1 -1
- package/dist/mime-registry-entry.vo.d.ts +2 -2
- package/dist/mime-registry.service.d.ts +1 -1
- package/dist/min-max-scaler.service.d.ts +1 -1
- package/dist/minute.vo.d.ts +1 -1
- package/dist/outlier-detector.service.d.ts +1 -1
- package/dist/pagination.service.d.ts +2 -2
- package/dist/population-standard-deviation.service.d.ts +1 -1
- package/dist/reordering.service.d.ts +2 -2
- package/dist/sum.service.d.ts +2 -2
- package/dist/ts-utils.d.ts +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/weekday-iso-id.vo.d.ts +7 -0
- package/dist/weekday-iso-id.vo.js +10 -0
- package/dist/weekday.vo.d.ts +2 -2
- package/dist/z-score.service.d.ts +1 -1
- package/package.json +8 -8
- package/readme.md +1 -2
- package/dist/clock-format.service.d.ts +0 -9
- package/dist/clock-format.service.js +0 -10
- package/dist/clock.vo.d.ts +0 -26
- package/dist/clock.vo.js +0 -43
package/dist/age.vo.js
CHANGED
package/dist/date-range.vo.d.ts
CHANGED
package/dist/date-range.vo.js
CHANGED
|
@@ -5,7 +5,7 @@ export class DateRange {
|
|
|
5
5
|
constructor(start, end) {
|
|
6
6
|
this.start = start;
|
|
7
7
|
this.end = end;
|
|
8
|
-
if (start.
|
|
8
|
+
if (start.isAfterOrEqual(end))
|
|
9
9
|
throw new Error(DateRangeError.Invalid);
|
|
10
10
|
}
|
|
11
11
|
getStart() {
|
|
@@ -23,6 +23,9 @@ export class DateRange {
|
|
|
23
23
|
equals(other) {
|
|
24
24
|
return this.start.equals(other.start) && this.end.equals(other.end);
|
|
25
25
|
}
|
|
26
|
+
toString() {
|
|
27
|
+
return `${this.start.toString()} - ${this.end.toString()}`;
|
|
28
|
+
}
|
|
26
29
|
toJSON() {
|
|
27
30
|
return { start: this.getStart().ms, end: this.getEnd().ms };
|
|
28
31
|
}
|
package/dist/dll.service.d.ts
CHANGED
|
@@ -23,7 +23,7 @@ export declare class DoublyLinkedList<T> {
|
|
|
23
23
|
insertBefore(node: Node<T>, target: Node<T>): void;
|
|
24
24
|
find(callback: (node: Node<T>) => boolean): Node<T> | null;
|
|
25
25
|
reverse(): void;
|
|
26
|
-
toArray(): Node<T
|
|
27
|
-
static fromArray<T>(array: T
|
|
26
|
+
toArray(): ReadonlyArray<Node<T>>;
|
|
27
|
+
static fromArray<T>(array: ReadonlyArray<T>): DoublyLinkedList<T>;
|
|
28
28
|
[Symbol.iterator](): IterableIterator<Node<T>>;
|
|
29
29
|
}
|
package/dist/hour.vo.d.ts
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -2,8 +2,6 @@ export * from "./age.vo";
|
|
|
2
2
|
export * from "./age-years.vo";
|
|
3
3
|
export * from "./api-key.vo";
|
|
4
4
|
export * from "./basename.vo";
|
|
5
|
-
export * from "./clock.vo";
|
|
6
|
-
export * from "./clock-format.service";
|
|
7
5
|
export * from "./date-calculator.service";
|
|
8
6
|
export * from "./date-formatter.service";
|
|
9
7
|
export * from "./date-range.vo";
|
|
@@ -99,6 +97,7 @@ export * from "./visually-unambiguous-characters-generator.service";
|
|
|
99
97
|
export * from "./week.vo";
|
|
100
98
|
export * from "./week-iso-id.vo";
|
|
101
99
|
export * from "./weekday.vo";
|
|
100
|
+
export * from "./weekday-iso-id.vo";
|
|
102
101
|
export * from "./weight.vo";
|
|
103
102
|
export * from "./weight-grams.vo";
|
|
104
103
|
export * from "./year.vo";
|
package/dist/index.js
CHANGED
|
@@ -2,8 +2,6 @@ export * from "./age.vo";
|
|
|
2
2
|
export * from "./age-years.vo";
|
|
3
3
|
export * from "./api-key.vo";
|
|
4
4
|
export * from "./basename.vo";
|
|
5
|
-
export * from "./clock.vo";
|
|
6
|
-
export * from "./clock-format.service";
|
|
7
5
|
export * from "./date-calculator.service";
|
|
8
6
|
export * from "./date-formatter.service";
|
|
9
7
|
export * from "./date-range.vo";
|
|
@@ -99,6 +97,7 @@ export * from "./visually-unambiguous-characters-generator.service";
|
|
|
99
97
|
export * from "./week.vo";
|
|
100
98
|
export * from "./week-iso-id.vo";
|
|
101
99
|
export * from "./weekday.vo";
|
|
100
|
+
export * from "./weekday-iso-id.vo";
|
|
102
101
|
export * from "./weight.vo";
|
|
103
102
|
export * from "./weight-grams.vo";
|
|
104
103
|
export * from "./year.vo";
|
|
@@ -21,7 +21,7 @@ export declare class LinearRegression {
|
|
|
21
21
|
private readonly params;
|
|
22
22
|
private readonly rounding;
|
|
23
23
|
constructor(params: LinearRegressionParamsType, rounding?: RoundingStrategy);
|
|
24
|
-
static fromPairs(pairs: LinearRegressionPairType
|
|
24
|
+
static fromPairs(pairs: ReadonlyArray<LinearRegressionPairType>, rounding?: RoundingStrategy): LinearRegression;
|
|
25
25
|
predict(x: LinearRegressionPairType["x"], rounding?: RoundingStrategy): LinearRegressionPredictionType;
|
|
26
26
|
inspect(): LinearRegression["params"];
|
|
27
27
|
}
|
package/dist/mean.service.d.ts
CHANGED
|
@@ -4,5 +4,5 @@ export declare const MeanError: {
|
|
|
4
4
|
};
|
|
5
5
|
export declare class Mean {
|
|
6
6
|
private static readonly DEFAULT_ROUNDING;
|
|
7
|
-
static calculate(values: number
|
|
7
|
+
static calculate(values: ReadonlyArray<number>, rounding?: RoundingStrategy): number;
|
|
8
8
|
}
|
|
@@ -2,6 +2,6 @@ import type { ExtensionType } from "./extension.vo";
|
|
|
2
2
|
import type { Mime } from "./mime.vo";
|
|
3
3
|
export declare class MimeRegistryEntry {
|
|
4
4
|
readonly mime: Mime;
|
|
5
|
-
readonly extensions: ExtensionType
|
|
6
|
-
constructor(mime: Mime, extensions: ExtensionType
|
|
5
|
+
readonly extensions: ReadonlyArray<ExtensionType>;
|
|
6
|
+
constructor(mime: Mime, extensions: ReadonlyArray<ExtensionType>);
|
|
7
7
|
}
|
|
@@ -8,7 +8,7 @@ export declare const MimeRegistryError: {
|
|
|
8
8
|
export declare class MimeRegistry {
|
|
9
9
|
private readonly byExtension;
|
|
10
10
|
private readonly byMime;
|
|
11
|
-
constructor(entries:
|
|
11
|
+
constructor(entries: ReadonlyArray<MimeRegistryEntry>);
|
|
12
12
|
hasExtension(extension: ExtensionType): boolean;
|
|
13
13
|
hasMime(mime: Mime): boolean;
|
|
14
14
|
fromExtension(extension: ExtensionType): Mime | undefined;
|
|
@@ -38,7 +38,7 @@ export declare class MinMaxScaler {
|
|
|
38
38
|
constructor(config: MinMaxScalerConfigType);
|
|
39
39
|
scale(value: MinMaxScalerValueType): ScaleResult;
|
|
40
40
|
descale(scaled: MinMaxScalerValueType): DescaleResult;
|
|
41
|
-
static getMinMax(values: MinMaxScalerValueType
|
|
41
|
+
static getMinMax(values: ReadonlyArray<MinMaxScalerValueType>): {
|
|
42
42
|
min: number;
|
|
43
43
|
max: number;
|
|
44
44
|
};
|
package/dist/minute.vo.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export declare class Minute {
|
|
|
14
14
|
equals(another: Minute): boolean;
|
|
15
15
|
isBefore(another: Minute): boolean;
|
|
16
16
|
isAfter(another: Minute): boolean;
|
|
17
|
-
static list():
|
|
17
|
+
static list(): ReadonlyArray<Minute>;
|
|
18
18
|
toString(): string;
|
|
19
19
|
toJSON(): number;
|
|
20
20
|
}
|
|
@@ -4,6 +4,6 @@ export declare const OutlierDetectorError: {
|
|
|
4
4
|
export declare class OutlierDetector {
|
|
5
5
|
private readonly zScore;
|
|
6
6
|
private readonly threshold;
|
|
7
|
-
constructor(values: number
|
|
7
|
+
constructor(values: ReadonlyArray<number>, threshold: number);
|
|
8
8
|
isInlier(value: number): boolean;
|
|
9
9
|
}
|
|
@@ -18,7 +18,7 @@ export type PaginationExhaustedConfig = {
|
|
|
18
18
|
export type PaginationPrepareConfigType<T> = {
|
|
19
19
|
total: TotalType;
|
|
20
20
|
pagination: PaginationType;
|
|
21
|
-
result: T
|
|
21
|
+
result: ReadonlyArray<T>;
|
|
22
22
|
};
|
|
23
23
|
export declare class Pagination {
|
|
24
24
|
static parse(values: PaginationValuesType, _take: TakeType): PaginationType;
|
|
@@ -41,7 +41,7 @@ export declare class Pagination {
|
|
|
41
41
|
}): PaginationType;
|
|
42
42
|
}
|
|
43
43
|
export type Paged<T> = {
|
|
44
|
-
result: T
|
|
44
|
+
result: ReadonlyArray<T>;
|
|
45
45
|
meta: {
|
|
46
46
|
exhausted: ExhaustedType;
|
|
47
47
|
currentPage: PageType;
|
|
@@ -3,5 +3,5 @@ export declare const PopulationStandardDeviationError: {
|
|
|
3
3
|
NotEnoughValues: string;
|
|
4
4
|
};
|
|
5
5
|
export declare class PopulationStandardDeviation {
|
|
6
|
-
static calculate(values: number
|
|
6
|
+
static calculate(values: ReadonlyArray<number>, rounding?: RoundingStrategy): number;
|
|
7
7
|
}
|
|
@@ -44,7 +44,7 @@ export declare class ReorderingTransfer {
|
|
|
44
44
|
export declare class ReorderingCalculator {
|
|
45
45
|
private dll;
|
|
46
46
|
constructor();
|
|
47
|
-
static fromArray(ids: ReorderingItem["id"]
|
|
47
|
+
static fromArray(ids: ReadonlyArray<ReorderingItem["id"]>): ReorderingCalculator;
|
|
48
48
|
add(id: ReorderingItem["id"]): ReorderingItem;
|
|
49
49
|
delete(id: ReorderingItem["id"]): void;
|
|
50
50
|
transfer(transfer: ReorderingTransfer): ReturnType<ReorderingCalculator["read"]>;
|
|
@@ -55,7 +55,7 @@ export declare class ReorderingCalculator {
|
|
|
55
55
|
private recalculate;
|
|
56
56
|
}
|
|
57
57
|
export declare class ReorderingIntegrator {
|
|
58
|
-
static appendPosition(reordering: ReorderingType
|
|
58
|
+
static appendPosition(reordering: ReadonlyArray<ReorderingType>): <T extends {
|
|
59
59
|
id: ReorderingItemIdType;
|
|
60
60
|
}>(item: T) => WithReorderingPositionValue<T>;
|
|
61
61
|
static sortByPosition(): (a: WithReorderingPositionValue<unknown>, b: WithReorderingPositionValue<unknown>) => number;
|
package/dist/sum.service.d.ts
CHANGED
package/dist/ts-utils.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"root":["../src/age-years.vo.ts","../src/age.vo.ts","../src/api-key.vo.ts","../src/basename.vo.ts","../src/
|
|
1
|
+
{"root":["../src/age-years.vo.ts","../src/age.vo.ts","../src/api-key.vo.ts","../src/basename.vo.ts","../src/date-calculator.service.ts","../src/date-formatter.service.ts","../src/date-range.vo.ts","../src/day-iso-id.vo.ts","../src/day.vo.ts","../src/directory-path-absolute.vo.ts","../src/directory-path-relative.vo.ts","../src/distance-value.vo.ts","../src/distance.vo.ts","../src/division-factor.vo.ts","../src/dll.service.ts","../src/duration-ms.vo.ts","../src/duration.service.ts","../src/email-mask.service.ts","../src/email.vo.ts","../src/etags.vo.ts","../src/extension.vo.ts","../src/feature-flag-value.vo.ts","../src/feature-flag.vo.ts","../src/file-path-absolute-schema.vo.ts","../src/file-path-relative-schema.vo.ts","../src/file-path.vo.ts","../src/filename-affix.vo.ts","../src/filename-from-string.vo.ts","../src/filename.vo.ts","../src/height-milimiters.vo.ts","../src/height.vo.ts","../src/hour-format.service.ts","../src/hour-schema.vo.ts","../src/hour.vo.ts","../src/iban-mask.service.ts","../src/iban-schema.vo.ts","../src/iban.vo.ts","../src/image.vo.ts","../src/index.ts","../src/integer-non-negative.vo.ts","../src/integer-positive.vo.ts","../src/integer.vo.ts","../src/language.vo.ts","../src/linear-regression.service.ts","../src/mean.service.ts","../src/mime-registry-entry.vo.ts","../src/mime-registry.service.ts","../src/mime-value.vo.ts","../src/mime.vo.ts","../src/mimes.ts","../src/min-max-scaler.service.ts","../src/minute-schema.vo.ts","../src/minute.vo.ts","../src/money-amount.vo.ts","../src/money.vo.ts","../src/month-iso-id.vo.ts","../src/month.vo.ts","../src/multiplication-factor.vo.ts","../src/noop.service.ts","../src/object-key.vo.ts","../src/outlier-detector.service.ts","../src/package-version-schema.vo.ts","../src/package-version.vo.ts","../src/pagination-page.vo.ts","../src/pagination-skip.vo.ts","../src/pagination-take.vo.ts","../src/pagination.service.ts","../src/percentage.service.ts","../src/population-standard-deviation.service.ts","../src/quarter-iso-id.vo.ts","../src/quarter.vo.ts","../src/random.service.ts","../src/rate-limiter.service.ts","../src/relative-date.vo.ts","../src/reordering-item-position-value.vo.ts","../src/reordering.service.ts","../src/revision-value.vo.ts","../src/revision.vo.ts","../src/rounding-decimal.strategy.ts","../src/rounding-down.strategy.ts","../src/rounding-to-nearest.strategy.ts","../src/rounding-up.strategy.ts","../src/rounding.strategy.ts","../src/size-bytes.vo.ts","../src/size.vo.ts","../src/slug.service.ts","../src/sum.service.ts","../src/thousands-separator.service.ts","../src/time-zone-offset-value.vo.ts","../src/timestamp-value.vo.ts","../src/timestamp.vo.ts","../src/timezone.vo.ts","../src/ts-utils.ts","../src/url-with-slash.vo.ts","../src/url-without-slash.vo.ts","../src/visually-unambiguous-characters-generator.service.ts","../src/week-iso-id.vo.ts","../src/week.vo.ts","../src/weekday-iso-id.vo.ts","../src/weekday.vo.ts","../src/weight-grams.vo.ts","../src/weight.vo.ts","../src/year-iso-id.vo.ts","../src/year.vo.ts","../src/z-score.service.ts"],"version":"5.9.3"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as z from "zod/v4";
|
|
2
|
+
export declare const WeekdayIsoIdError: {
|
|
3
|
+
Type: string;
|
|
4
|
+
Invalid: string;
|
|
5
|
+
};
|
|
6
|
+
export declare const WeekdayIsoId: z.core.$ZodBranded<z.ZodNumber, "WeekdayIsoId", "out">;
|
|
7
|
+
export type WeekdayIsoIdType = z.infer<typeof WeekdayIsoId>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as z from "zod/v4";
|
|
2
|
+
export const WeekdayIsoIdError = { Type: "weekday.iso.id.type", Invalid: "weekday.iso.id.invalid" };
|
|
3
|
+
// Stryker disable all
|
|
4
|
+
export const WeekdayIsoId = z
|
|
5
|
+
// Stryker restore all
|
|
6
|
+
.number(WeekdayIsoIdError.Type)
|
|
7
|
+
.int(WeekdayIsoIdError.Type)
|
|
8
|
+
.min(0, WeekdayIsoIdError.Invalid)
|
|
9
|
+
.max(6, WeekdayIsoIdError.Invalid)
|
|
10
|
+
.brand("WeekdayIsoId");
|
package/dist/weekday.vo.d.ts
CHANGED
|
@@ -37,6 +37,6 @@ export declare class Weekday {
|
|
|
37
37
|
isFriday(): boolean;
|
|
38
38
|
isSaturday(): boolean;
|
|
39
39
|
isSunday(): boolean;
|
|
40
|
-
static list(formatter?: WeekdayFormatter):
|
|
41
|
-
static listMondayFirst(formatter?: WeekdayFormatter):
|
|
40
|
+
static list(formatter?: WeekdayFormatter): ReadonlyArray<Weekday>;
|
|
41
|
+
static listMondayFirst(formatter?: WeekdayFormatter): ReadonlyArray<Weekday>;
|
|
42
42
|
}
|
|
@@ -6,6 +6,6 @@ export declare class ZScore {
|
|
|
6
6
|
private readonly rounding;
|
|
7
7
|
private readonly mean;
|
|
8
8
|
private readonly standardDeviation;
|
|
9
|
-
constructor(values: number
|
|
9
|
+
constructor(values: ReadonlyArray<number>, rounding?: RoundingStrategy);
|
|
10
10
|
calculate(value: number): number;
|
|
11
11
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bgord/tools",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.14",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Bartosz Gordon",
|
|
@@ -20,14 +20,14 @@
|
|
|
20
20
|
"preinstall": "bunx only-allow bun"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@biomejs/biome": "2.3.
|
|
24
|
-
"@commitlint/cli": "20.
|
|
25
|
-
"@commitlint/config-conventional": "20.
|
|
26
|
-
"@stryker-mutator/core": "9.
|
|
23
|
+
"@biomejs/biome": "2.3.14",
|
|
24
|
+
"@commitlint/cli": "20.4.1",
|
|
25
|
+
"@commitlint/config-conventional": "20.4.1",
|
|
26
|
+
"@stryker-mutator/core": "9.5.1",
|
|
27
27
|
"@types/bun": "1.3.8",
|
|
28
|
-
"cspell": "9.6.
|
|
29
|
-
"knip": "5.
|
|
30
|
-
"lefthook": "2.0
|
|
28
|
+
"cspell": "9.6.4",
|
|
29
|
+
"knip": "5.83.1",
|
|
30
|
+
"lefthook": "2.1.0",
|
|
31
31
|
"lockfile-lint": "5.0.0",
|
|
32
32
|
"only-allow": "1.2.2",
|
|
33
33
|
"shellcheck": "4.1.0",
|
package/readme.md
CHANGED
|
@@ -28,8 +28,6 @@ src/
|
|
|
28
28
|
├── age.vo.ts
|
|
29
29
|
├── api-key.vo.ts
|
|
30
30
|
├── basename.vo.ts
|
|
31
|
-
├── clock-format.service.ts
|
|
32
|
-
├── clock.vo.ts
|
|
33
31
|
├── date-calculator.service.ts
|
|
34
32
|
├── date-formatter.service.ts
|
|
35
33
|
├── date-range.vo.ts
|
|
@@ -123,6 +121,7 @@ src/
|
|
|
123
121
|
├── visually-unambiguous-characters-generator.service.ts
|
|
124
122
|
├── week-iso-id.vo.ts
|
|
125
123
|
├── week.vo.ts
|
|
124
|
+
├── weekday-iso-id.vo.ts
|
|
126
125
|
├── weekday.vo.ts
|
|
127
126
|
├── weight-grams.vo.ts
|
|
128
127
|
├── weight.vo.ts
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { Hour } from "./hour.vo";
|
|
2
|
-
import type { Minute } from "./minute.vo";
|
|
3
|
-
export type ClockFormatter = (hour: Hour, minute: Minute) => string;
|
|
4
|
-
declare enum ClockFormatterEnum {
|
|
5
|
-
TWENTY_FOUR_HOURS = "TWENTY_FOUR_HOURS",
|
|
6
|
-
TWELVE_HOURS = "TWELVE_HOURS"
|
|
7
|
-
}
|
|
8
|
-
export declare const ClockFormatters: Record<ClockFormatterEnum, ClockFormatter>;
|
|
9
|
-
export {};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { HourFormatters } from "./hour-format.service";
|
|
2
|
-
var ClockFormatterEnum;
|
|
3
|
-
(function (ClockFormatterEnum) {
|
|
4
|
-
ClockFormatterEnum["TWENTY_FOUR_HOURS"] = "TWENTY_FOUR_HOURS";
|
|
5
|
-
ClockFormatterEnum["TWELVE_HOURS"] = "TWELVE_HOURS";
|
|
6
|
-
})(ClockFormatterEnum || (ClockFormatterEnum = {}));
|
|
7
|
-
export const ClockFormatters = {
|
|
8
|
-
TWENTY_FOUR_HOURS: (hour, minute) => `${hour.toString()}:${minute.toString()}`,
|
|
9
|
-
TWELVE_HOURS: (hour, minute) => `${hour.format(HourFormatters.TWELVE_HOURS)}:${minute.toString()}`,
|
|
10
|
-
};
|
package/dist/clock.vo.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { type ClockFormatter } from "./clock-format.service";
|
|
2
|
-
import { Hour } from "./hour.vo";
|
|
3
|
-
import type { HourSchemaType } from "./hour-schema.vo";
|
|
4
|
-
import { Minute } from "./minute.vo";
|
|
5
|
-
import type { MinuteSchemaType } from "./minute-schema.vo";
|
|
6
|
-
import type { Timestamp } from "./timestamp.vo";
|
|
7
|
-
export declare class Clock {
|
|
8
|
-
private readonly hour;
|
|
9
|
-
private readonly minute;
|
|
10
|
-
private readonly formatter;
|
|
11
|
-
constructor(hour: Hour, minute: Minute, formatter?: ClockFormatter);
|
|
12
|
-
static fromTimestamp(timestamp: Timestamp, formatter?: ClockFormatter): Clock;
|
|
13
|
-
get(): {
|
|
14
|
-
hour: HourSchemaType;
|
|
15
|
-
minute: MinuteSchemaType;
|
|
16
|
-
};
|
|
17
|
-
format(): string;
|
|
18
|
-
equals(another: Clock): boolean;
|
|
19
|
-
isAfter(another: Clock): boolean;
|
|
20
|
-
isBefore(another: Clock): boolean;
|
|
21
|
-
toString(): string;
|
|
22
|
-
toJSON(): {
|
|
23
|
-
hour: HourSchemaType;
|
|
24
|
-
minute: MinuteSchemaType;
|
|
25
|
-
};
|
|
26
|
-
}
|
package/dist/clock.vo.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { ClockFormatters } from "./clock-format.service";
|
|
2
|
-
import { Hour } from "./hour.vo";
|
|
3
|
-
import { Minute } from "./minute.vo";
|
|
4
|
-
export class Clock {
|
|
5
|
-
hour;
|
|
6
|
-
minute;
|
|
7
|
-
formatter;
|
|
8
|
-
constructor(hour, minute, formatter) {
|
|
9
|
-
this.hour = hour;
|
|
10
|
-
this.minute = minute;
|
|
11
|
-
this.formatter = formatter ?? ClockFormatters.TWENTY_FOUR_HOURS;
|
|
12
|
-
}
|
|
13
|
-
static fromTimestamp(timestamp, formatter) {
|
|
14
|
-
const hour = Hour.fromTimestamp(timestamp);
|
|
15
|
-
const minute = Minute.fromTimestamp(timestamp);
|
|
16
|
-
return new Clock(hour, minute, formatter);
|
|
17
|
-
}
|
|
18
|
-
get() {
|
|
19
|
-
return { hour: this.hour.get(), minute: this.minute.get() };
|
|
20
|
-
}
|
|
21
|
-
format() {
|
|
22
|
-
return this.formatter(this.hour, this.minute);
|
|
23
|
-
}
|
|
24
|
-
equals(another) {
|
|
25
|
-
return this.hour.equals(another.hour) && this.minute.equals(another.minute);
|
|
26
|
-
}
|
|
27
|
-
isAfter(another) {
|
|
28
|
-
if (!this.hour.equals(another.hour))
|
|
29
|
-
return this.hour.isAfter(another.hour);
|
|
30
|
-
return this.minute.isAfter(another.minute);
|
|
31
|
-
}
|
|
32
|
-
isBefore(another) {
|
|
33
|
-
if (!this.hour.equals(another.hour))
|
|
34
|
-
return this.hour.isBefore(another.hour);
|
|
35
|
-
return this.minute.isBefore(another.minute);
|
|
36
|
-
}
|
|
37
|
-
toString() {
|
|
38
|
-
return this.format();
|
|
39
|
-
}
|
|
40
|
-
toJSON() {
|
|
41
|
-
return this.get();
|
|
42
|
-
}
|
|
43
|
-
}
|