@bgord/tools 1.2.9 → 1.2.11

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/day.vo.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { DateRange } from "./date-range.vo";
2
2
  import { type DayIsoIdType } from "./day-iso-id.vo";
3
+ import { type IntegerType } from "./integer.vo";
3
4
  import { Timestamp } from "./timestamp.vo";
4
5
  import type { TimestampValueType } from "./timestamp-value.vo";
5
6
  export declare class Day extends DateRange {
@@ -10,6 +11,6 @@ export declare class Day extends DateRange {
10
11
  toIsoId(): DayIsoIdType;
11
12
  previous(): Day;
12
13
  next(): Day;
13
- shift(count: number): Day;
14
+ shift(count: IntegerType): Day;
14
15
  toString(): string;
15
16
  }
package/dist/day.vo.js CHANGED
@@ -2,6 +2,7 @@ import { formatISO } from "date-fns";
2
2
  import { DateRange } from "./date-range.vo";
3
3
  import { DayIsoId } from "./day-iso-id.vo";
4
4
  import { Duration } from "./duration.service";
5
+ import { Integer } from "./integer.vo";
5
6
  import { Timestamp } from "./timestamp.vo";
6
7
  export class Day extends DateRange {
7
8
  static fromTimestamp(timestamp) {
@@ -27,10 +28,10 @@ export class Day extends DateRange {
27
28
  return DayIsoId.parse(formatISO(midday.ms, { representation: "date" }));
28
29
  }
29
30
  previous() {
30
- return this.shift(-1);
31
+ return this.shift(Integer.parse(-1));
31
32
  }
32
33
  next() {
33
- return this.shift(1);
34
+ return this.shift(Integer.parse(1));
34
35
  }
35
36
  shift(count) {
36
37
  return Day.fromTimestamp(this.getStart().add(Duration.Days(count)));
package/dist/index.d.ts CHANGED
@@ -39,6 +39,8 @@ export * from "./iban-mask.service";
39
39
  export * from "./iban-schema.vo";
40
40
  export * from "./image.vo";
41
41
  export * from "./index";
42
+ export * from "./integer.vo";
43
+ export * from "./integer-positive.vo";
42
44
  export * from "./language.vo";
43
45
  export * from "./linear-regression.service";
44
46
  export * from "./mean.service";
package/dist/index.js CHANGED
@@ -39,6 +39,8 @@ export * from "./iban-mask.service";
39
39
  export * from "./iban-schema.vo";
40
40
  export * from "./image.vo";
41
41
  export * from "./index";
42
+ export * from "./integer.vo";
43
+ export * from "./integer-positive.vo";
42
44
  export * from "./language.vo";
43
45
  export * from "./linear-regression.service";
44
46
  export * from "./mean.service";
@@ -0,0 +1,7 @@
1
+ import { z } from "zod/v4";
2
+ export declare const IntegerPositiveError: {
3
+ Type: string;
4
+ Invalid: string;
5
+ };
6
+ export declare const IntegerPositive: z.core.$ZodBranded<z.ZodNumber, "IntegerPositive">;
7
+ export type IntegerPositiveType = z.infer<typeof IntegerPositive>;
@@ -0,0 +1,7 @@
1
+ import { z } from "zod/v4";
2
+ export const IntegerPositiveError = { Type: "integer.positive.type", Invalid: "integer.positive.invalid" };
3
+ export const IntegerPositive = z
4
+ .number(IntegerPositiveError.Type)
5
+ .int(IntegerPositiveError.Type)
6
+ .min(1, IntegerPositiveError.Invalid)
7
+ .brand("IntegerPositive");
@@ -0,0 +1,6 @@
1
+ import { z } from "zod/v4";
2
+ export declare const IntegerError: {
3
+ Type: string;
4
+ };
5
+ export declare const Integer: z.core.$ZodBranded<z.ZodNumber, "Integer">;
6
+ export type IntegerType = z.infer<typeof Integer>;
@@ -0,0 +1,3 @@
1
+ import { z } from "zod/v4";
2
+ export const IntegerError = { Type: "integer.type" };
3
+ export const Integer = z.number(IntegerError.Type).int(IntegerError.Type).brand("Integer");
@@ -1,4 +1,5 @@
1
1
  import { DateRange } from "./date-range.vo";
2
+ import { type IntegerType } from "./integer.vo";
2
3
  import { type MonthIsoIdType } from "./month-iso-id.vo";
3
4
  import { Timestamp } from "./timestamp.vo";
4
5
  import type { TimestampValueType } from "./timestamp-value.vo";
@@ -10,6 +11,6 @@ export declare class Month extends DateRange {
10
11
  toIsoId(): MonthIsoIdType;
11
12
  previous(): Month;
12
13
  next(): Month;
13
- shift(count: number): Month;
14
+ shift(count: IntegerType): Month;
14
15
  toString(): string;
15
16
  }
package/dist/month.vo.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { endOfMonth, format, getMonth, setMonth, startOfMonth } from "date-fns";
2
2
  import { DateRange } from "./date-range.vo";
3
+ import { Integer } from "./integer.vo";
3
4
  import { MonthIsoId } from "./month-iso-id.vo";
4
5
  import { Timestamp } from "./timestamp.vo";
5
6
  export class Month extends DateRange {
@@ -23,10 +24,10 @@ export class Month extends DateRange {
23
24
  return MonthIsoId.parse(format(this.getStart().ms, "yyyy-MM"));
24
25
  }
25
26
  previous() {
26
- return this.shift(-1);
27
+ return this.shift(Integer.parse(-1));
27
28
  }
28
29
  next() {
29
- return this.shift(1);
30
+ return this.shift(Integer.parse(1));
30
31
  }
31
32
  shift(count) {
32
33
  const shifted = setMonth(this.getStart().ms, getMonth(this.getStart().ms) + count).getTime();
@@ -1 +1 @@
1
- {"root":["../src/age-years.vo.ts","../src/age.vo.ts","../src/api-key.vo.ts","../src/basename.vo.ts","../src/clock-format.service.ts","../src/clock.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/language.vo.ts","../src/linear-regression.service.ts","../src/mean.service.ts","../src/mime-types.vo.ts","../src/mime-value.vo.ts","../src/mime.vo.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/notification-template.vo.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.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"}
1
+ {"root":["../src/age-years.vo.ts","../src/age.vo.ts","../src/api-key.vo.ts","../src/basename.vo.ts","../src/clock-format.service.ts","../src/clock.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-positive.vo.ts","../src/integer.vo.ts","../src/language.vo.ts","../src/linear-regression.service.ts","../src/mean.service.ts","../src/mime-types.vo.ts","../src/mime-value.vo.ts","../src/mime.vo.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/notification-template.vo.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.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"}
package/dist/week.vo.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { DateRange } from "./date-range.vo";
2
+ import { type IntegerType } from "./integer.vo";
2
3
  import { Timestamp } from "./timestamp.vo";
3
4
  import type { TimestampValueType } from "./timestamp-value.vo";
4
5
  import { type WeekIsoIdType } from "./week-iso-id.vo";
@@ -10,6 +11,6 @@ export declare class Week extends DateRange {
10
11
  toIsoId(): WeekIsoIdType;
11
12
  previous(): Week;
12
13
  next(): Week;
13
- shift(count: number): Week;
14
+ shift(count: IntegerType): Week;
14
15
  toString(): string;
15
16
  }
package/dist/week.vo.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { addWeeks, endOfISOWeek, getISOWeek, getISOWeekYear, setISOWeek, startOfISOWeek } from "date-fns";
2
2
  import { DateRange } from "./date-range.vo";
3
+ import { Integer } from "./integer.vo";
3
4
  import { Timestamp } from "./timestamp.vo";
4
5
  import { WeekIsoId } from "./week-iso-id.vo";
5
6
  export class Week extends DateRange {
@@ -26,10 +27,10 @@ export class Week extends DateRange {
26
27
  return WeekIsoId.parse(`${year}-W${String(week).padStart(2, "0")}`);
27
28
  }
28
29
  previous() {
29
- return this.shift(-1);
30
+ return this.shift(Integer.parse(-1));
30
31
  }
31
32
  next() {
32
- return this.shift(1);
33
+ return this.shift(Integer.parse(1));
33
34
  }
34
35
  shift(count) {
35
36
  const shifted = addWeeks(this.getStart().ms, count).getTime();
package/dist/weight.vo.js CHANGED
@@ -16,7 +16,7 @@ export class Weight {
16
16
  return new Weight(WeightGrams.parse(grams), rounding);
17
17
  }
18
18
  static zero() {
19
- return new Weight(0);
19
+ return new Weight(WeightGrams.parse(0));
20
20
  }
21
21
  get() {
22
22
  return this.grams;
@@ -29,11 +29,11 @@ export class Weight {
29
29
  return `${this.grams} g`;
30
30
  }
31
31
  add(other) {
32
- return new Weight(this.grams + other.grams);
32
+ return new Weight(WeightGrams.parse(this.grams + other.grams));
33
33
  }
34
34
  subtract(other) {
35
35
  const result = this.grams - other.grams;
36
- return new Weight(result < 0 ? 0 : result);
36
+ return new Weight(WeightGrams.parse(result < 0 ? 0 : result));
37
37
  }
38
38
  multiply(factor) {
39
39
  const grams = this.rounding.round(this.grams * factor);
package/dist/year.vo.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { DateRange } from "./date-range.vo";
2
+ import { type IntegerType } from "./integer.vo";
2
3
  import { Timestamp } from "./timestamp.vo";
3
4
  import type { TimestampValueType } from "./timestamp-value.vo";
4
5
  import { type YearIsoIdType } from "./year-iso-id.vo";
@@ -12,6 +13,6 @@ export declare class Year extends DateRange {
12
13
  isLeapYear(): boolean;
13
14
  previous(): Year;
14
15
  next(): Year;
15
- shift(count: number): Year;
16
+ shift(count: IntegerType): Year;
16
17
  toString(): string;
17
18
  }
package/dist/year.vo.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { addYears, endOfYear, getYear, startOfYear } from "date-fns";
2
2
  import { DateRange } from "./date-range.vo";
3
+ import { Integer } from "./integer.vo";
3
4
  import { Timestamp } from "./timestamp.vo";
4
5
  import { YearIsoId } from "./year-iso-id.vo";
5
6
  export class Year extends DateRange {
@@ -29,10 +30,10 @@ export class Year extends DateRange {
29
30
  return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
30
31
  }
31
32
  previous() {
32
- return this.shift(-1);
33
+ return this.shift(Integer.parse(-1));
33
34
  }
34
35
  next() {
35
- return this.shift(1);
36
+ return this.shift(Integer.parse(1));
36
37
  }
37
38
  shift(count) {
38
39
  const shifted = addYears(this.getStart().ms, count).getTime();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bgord/tools",
3
- "version": "1.2.9",
3
+ "version": "1.2.11",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Bartosz Gordon",
package/readme.md CHANGED
@@ -64,6 +64,8 @@ src/
64
64
  ├── iban-schema.vo.ts
65
65
  ├── iban.vo.ts
66
66
  ├── image.vo.ts
67
+ ├── integer-positive.vo.ts
68
+ ├── integer.vo.ts
67
69
  ├── language.vo.ts
68
70
  ├── linear-regression.service.ts
69
71
  ├── mean.service.ts
package/src/day.vo.ts CHANGED
@@ -2,6 +2,7 @@ import { formatISO } from "date-fns";
2
2
  import { DateRange } from "./date-range.vo";
3
3
  import { DayIsoId, type DayIsoIdType } from "./day-iso-id.vo";
4
4
  import { Duration } from "./duration.service";
5
+ import { Integer, type IntegerType } from "./integer.vo";
5
6
  import { Timestamp } from "./timestamp.vo";
6
7
  import type { TimestampValueType } from "./timestamp-value.vo";
7
8
 
@@ -41,14 +42,14 @@ export class Day extends DateRange {
41
42
  }
42
43
 
43
44
  previous(): Day {
44
- return this.shift(-1);
45
+ return this.shift(Integer.parse(-1));
45
46
  }
46
47
 
47
48
  next(): Day {
48
- return this.shift(1);
49
+ return this.shift(Integer.parse(1));
49
50
  }
50
51
 
51
- shift(count: number): Day {
52
+ shift(count: IntegerType): Day {
52
53
  return Day.fromTimestamp(this.getStart().add(Duration.Days(count)));
53
54
  }
54
55
 
package/src/index.ts CHANGED
@@ -39,6 +39,8 @@ export * from "./iban-mask.service";
39
39
  export * from "./iban-schema.vo";
40
40
  export * from "./image.vo";
41
41
  export * from "./index";
42
+ export * from "./integer.vo";
43
+ export * from "./integer-positive.vo";
42
44
  export * from "./language.vo";
43
45
  export * from "./linear-regression.service";
44
46
  export * from "./mean.service";
@@ -0,0 +1,11 @@
1
+ import { z } from "zod/v4";
2
+
3
+ export const IntegerPositiveError = { Type: "integer.positive.type", Invalid: "integer.positive.invalid" };
4
+
5
+ export const IntegerPositive = z
6
+ .number(IntegerPositiveError.Type)
7
+ .int(IntegerPositiveError.Type)
8
+ .min(1, IntegerPositiveError.Invalid)
9
+ .brand("IntegerPositive");
10
+
11
+ export type IntegerPositiveType = z.infer<typeof IntegerPositive>;
@@ -0,0 +1,7 @@
1
+ import { z } from "zod/v4";
2
+
3
+ export const IntegerError = { Type: "integer.type" };
4
+
5
+ export const Integer = z.number(IntegerError.Type).int(IntegerError.Type).brand("Integer");
6
+
7
+ export type IntegerType = z.infer<typeof Integer>;
package/src/month.vo.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { endOfMonth, format, getMonth, setMonth, startOfMonth } from "date-fns";
2
2
  import { DateRange } from "./date-range.vo";
3
+ import { Integer, type IntegerType } from "./integer.vo";
3
4
  import { MonthIsoId, type MonthIsoIdType } from "./month-iso-id.vo";
4
5
  import { Timestamp } from "./timestamp.vo";
5
6
  import type { TimestampValueType } from "./timestamp-value.vo";
@@ -33,14 +34,14 @@ export class Month extends DateRange {
33
34
  }
34
35
 
35
36
  previous(): Month {
36
- return this.shift(-1);
37
+ return this.shift(Integer.parse(-1));
37
38
  }
38
39
 
39
40
  next(): Month {
40
- return this.shift(1);
41
+ return this.shift(Integer.parse(1));
41
42
  }
42
43
 
43
- shift(count: number): Month {
44
+ shift(count: IntegerType): Month {
44
45
  const shifted = setMonth(this.getStart().ms, getMonth(this.getStart().ms) + count).getTime();
45
46
 
46
47
  return Month.fromTimestamp(Timestamp.fromNumber(shifted));
package/src/week.vo.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { addWeeks, endOfISOWeek, getISOWeek, getISOWeekYear, setISOWeek, startOfISOWeek } from "date-fns";
2
2
  import { DateRange } from "./date-range.vo";
3
+ import { Integer, type IntegerType } from "./integer.vo";
3
4
  import { Timestamp } from "./timestamp.vo";
4
5
  import type { TimestampValueType } from "./timestamp-value.vo";
5
6
  import { WeekIsoId, type WeekIsoIdType } from "./week-iso-id.vo";
@@ -37,14 +38,14 @@ export class Week extends DateRange {
37
38
  }
38
39
 
39
40
  previous(): Week {
40
- return this.shift(-1);
41
+ return this.shift(Integer.parse(-1));
41
42
  }
42
43
 
43
44
  next(): Week {
44
- return this.shift(1);
45
+ return this.shift(Integer.parse(1));
45
46
  }
46
47
 
47
- shift(count: number): Week {
48
+ shift(count: IntegerType): Week {
48
49
  const shifted = addWeeks(this.getStart().ms, count).getTime();
49
50
 
50
51
  return Week.fromTimestamp(Timestamp.fromNumber(shifted));
package/src/weight.vo.ts CHANGED
@@ -2,13 +2,13 @@ import type { DivisionFactorType } from "./division-factor.vo";
2
2
  import type { MultiplicationFactorType } from "./multiplication-factor.vo";
3
3
  import type { RoundingStrategy } from "./rounding.strategy";
4
4
  import { RoundingToNearestStrategy } from "./rounding-to-nearest.strategy";
5
- import { WeightGrams } from "./weight-grams.vo";
5
+ import { WeightGrams, type WeightGramsType } from "./weight-grams.vo";
6
6
 
7
7
  export class Weight {
8
8
  private static readonly GRAMS_PER_KILOGRAM = 1_000;
9
9
 
10
10
  private constructor(
11
- private readonly grams: number,
11
+ private readonly grams: WeightGramsType,
12
12
  private readonly rounding: RoundingStrategy = new RoundingToNearestStrategy(),
13
13
  ) {}
14
14
 
@@ -26,7 +26,7 @@ export class Weight {
26
26
  }
27
27
 
28
28
  static zero(): Weight {
29
- return new Weight(0);
29
+ return new Weight(WeightGrams.parse(0));
30
30
  }
31
31
 
32
32
  get(): number {
@@ -44,13 +44,13 @@ export class Weight {
44
44
  }
45
45
 
46
46
  add(other: Weight): Weight {
47
- return new Weight(this.grams + other.grams);
47
+ return new Weight(WeightGrams.parse(this.grams + other.grams));
48
48
  }
49
49
 
50
50
  subtract(other: Weight): Weight {
51
51
  const result = this.grams - other.grams;
52
52
 
53
- return new Weight(result < 0 ? 0 : result);
53
+ return new Weight(WeightGrams.parse(result < 0 ? 0 : result));
54
54
  }
55
55
 
56
56
  multiply(factor: MultiplicationFactorType): Weight {
package/src/year.vo.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { addYears, endOfYear, getYear, startOfYear } from "date-fns";
2
2
  import { DateRange } from "./date-range.vo";
3
+ import { Integer, type IntegerType } from "./integer.vo";
3
4
  import { Timestamp } from "./timestamp.vo";
4
5
  import type { TimestampValueType } from "./timestamp-value.vo";
5
6
  import { YearIsoId, type YearIsoIdType } from "./year-iso-id.vo";
@@ -41,14 +42,14 @@ export class Year extends DateRange {
41
42
  }
42
43
 
43
44
  previous(): Year {
44
- return this.shift(-1);
45
+ return this.shift(Integer.parse(-1));
45
46
  }
46
47
 
47
48
  next(): Year {
48
- return this.shift(1);
49
+ return this.shift(Integer.parse(1));
49
50
  }
50
51
 
51
- shift(count: number): Year {
52
+ shift(count: IntegerType): Year {
52
53
  const shifted = addYears(this.getStart().ms, count).getTime();
53
54
 
54
55
  return Year.fromTimestamp(Timestamp.fromNumber(shifted));