@bgord/tools 1.2.12 → 1.2.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.
Files changed (147) hide show
  1. package/dist/age-years.vo.d.ts +1 -1
  2. package/dist/age-years.vo.js +2 -0
  3. package/dist/api-key.vo.d.ts +1 -1
  4. package/dist/api-key.vo.js +2 -0
  5. package/dist/basename.vo.d.ts +1 -1
  6. package/dist/basename.vo.js +2 -0
  7. package/dist/day-iso-id.vo.d.ts +1 -1
  8. package/dist/day-iso-id.vo.js +2 -0
  9. package/dist/directory-path-absolute.vo.d.ts +1 -1
  10. package/dist/directory-path-absolute.vo.js +2 -0
  11. package/dist/directory-path-relative.vo.d.ts +1 -1
  12. package/dist/directory-path-relative.vo.js +3 -1
  13. package/dist/distance-value.vo.d.ts +1 -1
  14. package/dist/distance-value.vo.js +2 -0
  15. package/dist/division-factor.vo.d.ts +1 -1
  16. package/dist/division-factor.vo.js +2 -0
  17. package/dist/dll.service.js +2 -6
  18. package/dist/duration-ms.vo.d.ts +1 -1
  19. package/dist/duration-ms.vo.js +1 -0
  20. package/dist/email.vo.d.ts +1 -1
  21. package/dist/email.vo.js +1 -0
  22. package/dist/etags.vo.js +0 -2
  23. package/dist/extension.vo.d.ts +1 -1
  24. package/dist/extension.vo.js +2 -0
  25. package/dist/file-path-absolute-schema.vo.d.ts +1 -1
  26. package/dist/file-path-absolute-schema.vo.js +2 -0
  27. package/dist/file-path-relative-schema.vo.d.ts +1 -1
  28. package/dist/file-path-relative-schema.vo.js +2 -0
  29. package/dist/filename-affix.vo.d.ts +1 -1
  30. package/dist/filename-affix.vo.js +2 -0
  31. package/dist/height-milimiters.vo.d.ts +1 -1
  32. package/dist/height-milimiters.vo.js +2 -0
  33. package/dist/hour-schema.vo.d.ts +1 -1
  34. package/dist/hour-schema.vo.js +3 -1
  35. package/dist/iban-schema.vo.d.ts +1 -1
  36. package/dist/iban-schema.vo.js +2 -0
  37. package/dist/image.vo.d.ts +2 -2
  38. package/dist/image.vo.js +4 -0
  39. package/dist/integer-non-negative.vo.d.ts +1 -1
  40. package/dist/integer-non-negative.vo.js +2 -0
  41. package/dist/integer-positive.vo.d.ts +1 -1
  42. package/dist/integer-positive.vo.js +2 -0
  43. package/dist/integer.vo.d.ts +1 -1
  44. package/dist/integer.vo.js +1 -0
  45. package/dist/linear-regression.service.js +2 -0
  46. package/dist/mime-value.vo.d.ts +1 -1
  47. package/dist/mime-value.vo.js +2 -0
  48. package/dist/min-max-scaler.service.js +1 -1
  49. package/dist/minute-schema.vo.d.ts +1 -1
  50. package/dist/minute-schema.vo.js +2 -0
  51. package/dist/minute.vo.d.ts +1 -1
  52. package/dist/minute.vo.js +3 -3
  53. package/dist/money-amount.vo.d.ts +1 -1
  54. package/dist/money-amount.vo.js +2 -0
  55. package/dist/month-iso-id.vo.d.ts +1 -1
  56. package/dist/month-iso-id.vo.js +2 -0
  57. package/dist/multiplication-factor.vo.d.ts +1 -1
  58. package/dist/multiplication-factor.vo.js +2 -0
  59. package/dist/object-key.vo.d.ts +1 -1
  60. package/dist/object-key.vo.js +2 -0
  61. package/dist/package-version-schema.vo.d.ts +1 -1
  62. package/dist/package-version-schema.vo.js +2 -0
  63. package/dist/package-version.vo.js +1 -5
  64. package/dist/pagination-page.vo.js +1 -1
  65. package/dist/percentage.service.js +0 -2
  66. package/dist/quarter-iso-id.vo.d.ts +1 -1
  67. package/dist/quarter-iso-id.vo.js +2 -0
  68. package/dist/random.service.js +1 -3
  69. package/dist/reordering.service.js +2 -0
  70. package/dist/rounding-decimal.strategy.d.ts +1 -1
  71. package/dist/rounding-decimal.strategy.js +2 -0
  72. package/dist/size-bytes.vo.d.ts +1 -1
  73. package/dist/size-bytes.vo.js +2 -0
  74. package/dist/time-zone-offset-value.vo.d.ts +1 -1
  75. package/dist/time-zone-offset-value.vo.js +6 -4
  76. package/dist/timestamp-value.vo.d.ts +1 -1
  77. package/dist/timestamp-value.vo.js +2 -0
  78. package/dist/timezone.vo.d.ts +1 -1
  79. package/dist/timezone.vo.js +2 -0
  80. package/dist/url-with-slash.vo.d.ts +1 -1
  81. package/dist/url-with-slash.vo.js +3 -1
  82. package/dist/url-without-slash.vo.d.ts +1 -1
  83. package/dist/url-without-slash.vo.js +3 -1
  84. package/dist/week-iso-id.vo.d.ts +1 -1
  85. package/dist/week-iso-id.vo.js +2 -0
  86. package/dist/weekday.vo.d.ts +3 -1
  87. package/dist/weekday.vo.js +4 -3
  88. package/dist/weight-grams.vo.d.ts +1 -1
  89. package/dist/weight-grams.vo.js +2 -0
  90. package/dist/weight.vo.d.ts +0 -2
  91. package/dist/weight.vo.js +1 -7
  92. package/dist/year-iso-id.vo.d.ts +1 -1
  93. package/dist/year-iso-id.vo.js +2 -0
  94. package/dist/year.vo.js +5 -1
  95. package/package.json +4 -3
  96. package/src/age-years.vo.ts +2 -0
  97. package/src/api-key.vo.ts +2 -0
  98. package/src/basename.vo.ts +2 -0
  99. package/src/day-iso-id.vo.ts +2 -0
  100. package/src/directory-path-absolute.vo.ts +2 -0
  101. package/src/directory-path-relative.vo.ts +3 -1
  102. package/src/distance-value.vo.ts +2 -0
  103. package/src/division-factor.vo.ts +2 -0
  104. package/src/dll.service.ts +4 -8
  105. package/src/duration-ms.vo.ts +2 -0
  106. package/src/email.vo.ts +2 -0
  107. package/src/etags.vo.ts +0 -2
  108. package/src/extension.vo.ts +2 -0
  109. package/src/file-path-absolute-schema.vo.ts +2 -0
  110. package/src/file-path-relative-schema.vo.ts +2 -0
  111. package/src/filename-affix.vo.ts +2 -0
  112. package/src/height-milimiters.vo.ts +2 -0
  113. package/src/hour-schema.vo.ts +3 -1
  114. package/src/iban-schema.vo.ts +2 -0
  115. package/src/image.vo.ts +4 -0
  116. package/src/integer-non-negative.vo.ts +2 -0
  117. package/src/integer-positive.vo.ts +2 -0
  118. package/src/integer.vo.ts +2 -0
  119. package/src/linear-regression.service.ts +2 -0
  120. package/src/mime-value.vo.ts +2 -0
  121. package/src/min-max-scaler.service.ts +1 -1
  122. package/src/minute-schema.vo.ts +2 -0
  123. package/src/minute.vo.ts +4 -4
  124. package/src/money-amount.vo.ts +2 -0
  125. package/src/month-iso-id.vo.ts +2 -0
  126. package/src/multiplication-factor.vo.ts +2 -0
  127. package/src/object-key.vo.ts +2 -0
  128. package/src/package-version-schema.vo.ts +2 -0
  129. package/src/package-version.vo.ts +1 -4
  130. package/src/pagination-page.vo.ts +1 -1
  131. package/src/percentage.service.ts +0 -1
  132. package/src/quarter-iso-id.vo.ts +2 -0
  133. package/src/random.service.ts +1 -2
  134. package/src/reordering.service.ts +2 -0
  135. package/src/rounding-decimal.strategy.ts +2 -0
  136. package/src/size-bytes.vo.ts +2 -0
  137. package/src/time-zone-offset-value.vo.ts +6 -4
  138. package/src/timestamp-value.vo.ts +2 -0
  139. package/src/timezone.vo.ts +2 -0
  140. package/src/url-with-slash.vo.ts +3 -1
  141. package/src/url-without-slash.vo.ts +3 -1
  142. package/src/week-iso-id.vo.ts +2 -0
  143. package/src/weekday.vo.ts +4 -2
  144. package/src/weight-grams.vo.ts +2 -0
  145. package/src/weight.vo.ts +1 -9
  146. package/src/year-iso-id.vo.ts +2 -0
  147. package/src/year.vo.ts +3 -1
@@ -28,11 +28,7 @@ export class PackageVersion {
28
28
  return true;
29
29
  if (this.minor < another.minor)
30
30
  return false;
31
- if (this.patch > another.patch)
32
- return true;
33
- if (this.patch < another.patch)
34
- return false;
35
- return true;
31
+ return this.patch >= another.patch;
36
32
  }
37
33
  toString() {
38
34
  return `${this.major}.${this.minor}.${this.patch}`;
@@ -1,5 +1,5 @@
1
1
  import { z } from "zod/v4";
2
- export const PaginationPageError = { Type: "pagination.page.Type" };
2
+ export const PaginationPageError = { Type: "pagination.page.type" };
3
3
  export const Page = z.coerce
4
4
  .number(PaginationPageError.Type)
5
5
  .int(PaginationPageError.Type)
@@ -4,8 +4,6 @@ export class Percentage {
4
4
  static of(numerator, denominator, rounding = new RoundingToNearestStrategy()) {
5
5
  if (denominator === 0)
6
6
  throw new Error(PercentageError.InvalidDenominator);
7
- if (numerator === 0)
8
- return 0;
9
7
  return rounding.round((numerator / denominator) * 100);
10
8
  }
11
9
  }
@@ -3,5 +3,5 @@ export declare const QuarterIsoIdError: {
3
3
  Type: string;
4
4
  BadChars: string;
5
5
  };
6
- export declare const QuarterIsoId: z.core.$ZodBranded<z.ZodString, "QuarterIsoId">;
6
+ export declare const QuarterIsoId: z.core.$ZodBranded<z.ZodString, "QuarterIsoId", "out">;
7
7
  export type QuarterIsoIdType = z.infer<typeof QuarterIsoId>;
@@ -3,7 +3,9 @@ export const QuarterIsoIdError = {
3
3
  Type: "quarter.iso.id.type",
4
4
  BadChars: "quarter.iso.id.bad.chars",
5
5
  };
6
+ // Stryker disable all
6
7
  export const QuarterIsoId = z
8
+ // Stryker restore all
7
9
  .string(QuarterIsoIdError.Type)
8
10
  .regex(/^\d{4}-Q[1-4]$/, QuarterIsoIdError.BadChars)
9
11
  .brand("QuarterIsoId");
@@ -6,9 +6,7 @@ export class Random {
6
6
  static generate(config) {
7
7
  const min = config ? config.min : Random.DEFAULT_MIN;
8
8
  const max = config ? config.max : Random.DEFAULT_MAX;
9
- if (min === max)
10
- throw new Error(RandomError.MinMax);
11
- if (min > max)
9
+ if (min >= max)
12
10
  throw new Error(RandomError.MinMax);
13
11
  return new RoundingDownStrategy().round(Math.random() * (max - min + 1)) + min;
14
12
  }
@@ -1,3 +1,4 @@
1
+ // Stryker disable all
1
2
  import { z } from "zod/v4";
2
3
  import { DoublyLinkedList, Node } from "./dll.service";
3
4
  import { ReorderingItemPositionValue, } from "./reordering-item-position-value.vo";
@@ -131,3 +132,4 @@ export class ReorderingIntegrator {
131
132
  return (a, b) => a.position - b.position;
132
133
  }
133
134
  }
135
+ // Stryker restore all
@@ -4,7 +4,7 @@ export declare const RoundingDecimalError: {
4
4
  Type: string;
5
5
  Invalid: string;
6
6
  };
7
- export declare const RoundingDecimal: z.core.$ZodBranded<z.ZodNumber, "RoundingDecimal">;
7
+ export declare const RoundingDecimal: z.core.$ZodBranded<z.ZodNumber, "RoundingDecimal", "out">;
8
8
  export declare class RoundingDecimalStrategy implements RoundingStrategy {
9
9
  private readonly decimals;
10
10
  constructor(candidate: number);
@@ -1,6 +1,8 @@
1
1
  import { z } from "zod/v4";
2
2
  export const RoundingDecimalError = { Type: "rounding.decimal.type", Invalid: "rounding.decimal.invalid" };
3
+ // Stryker disable all
3
4
  export const RoundingDecimal = z
5
+ // Stryker restore all
4
6
  .number(RoundingDecimalError.Type)
5
7
  .int(RoundingDecimalError.Invalid)
6
8
  .min(1, RoundingDecimalError.Invalid)
@@ -2,5 +2,5 @@ import { z } from "zod/v4";
2
2
  export declare const SizeBytesError: {
3
3
  Invalid: string;
4
4
  };
5
- export declare const SizeBytes: z.core.$ZodBranded<z.ZodNumber, "SizeBytes">;
5
+ export declare const SizeBytes: z.core.$ZodBranded<z.ZodNumber, "SizeBytes", "out">;
6
6
  export type SizeBytesType = z.infer<typeof SizeBytes>;
@@ -1,6 +1,8 @@
1
1
  import { z } from "zod/v4";
2
2
  export const SizeBytesError = { Invalid: "size.bytes.invalid" };
3
+ // Stryker disable all
3
4
  export const SizeBytes = z
5
+ // Stryker restore all
4
6
  .number(SizeBytesError.Invalid)
5
7
  .int(SizeBytesError.Invalid)
6
8
  .gte(0, SizeBytesError.Invalid)
@@ -4,5 +4,5 @@ export declare const TimeZoneOffsetValueError: {
4
4
  Min: string;
5
5
  Max: string;
6
6
  };
7
- export declare const TimeZoneOffsetValue: z.core.$ZodBranded<z.ZodDefault<z.ZodCoercedNumber<unknown>>, "TimeZoneOffsetValue">;
7
+ export declare const TimeZoneOffsetValue: z.core.$ZodBranded<z.ZodDefault<z.ZodCoercedNumber<unknown>>, "TimeZoneOffsetValue", "out">;
8
8
  export type TimeZoneOffsetValueType = z.infer<typeof TimeZoneOffsetValue>;
@@ -4,12 +4,14 @@ export const TimeZoneOffsetValueError = {
4
4
  Min: "time.zone.offset.value.min",
5
5
  Max: "time.zone.offset.value.max",
6
6
  };
7
+ // Stryker disable all
7
8
  export const TimeZoneOffsetValue = z.coerce
8
- .number({ error: TimeZoneOffsetValueError.Type })
9
- .int({ error: TimeZoneOffsetValueError.Type })
9
+ // Stryker restore all
10
+ .number(TimeZoneOffsetValueError.Type)
11
+ .int(TimeZoneOffsetValueError.Type)
10
12
  // UTC+14 (Kiribati)
11
- .min(-840, { error: TimeZoneOffsetValueError.Min })
13
+ .min(-840, TimeZoneOffsetValueError.Min)
12
14
  // UTC-12 (Baker Island)
13
- .max(720, { error: TimeZoneOffsetValueError.Max })
15
+ .max(720, TimeZoneOffsetValueError.Max)
14
16
  .default(0) // Default to UTC if missing or invalid
15
17
  .brand("TimeZoneOffsetValue");
@@ -2,5 +2,5 @@ import { z } from "zod/v4";
2
2
  export declare const TimestampValueError: {
3
3
  Invalid: string;
4
4
  };
5
- export declare const TimestampValue: z.core.$ZodBranded<z.ZodNumber, "TimestampValue">;
5
+ export declare const TimestampValue: z.core.$ZodBranded<z.ZodNumber, "TimestampValue", "out">;
6
6
  export type TimestampValueType = z.infer<typeof TimestampValue>;
@@ -1,6 +1,8 @@
1
1
  import { z } from "zod/v4";
2
2
  export const TimestampValueError = { Invalid: "timestamp.invalid" };
3
+ // Stryker disable all
3
4
  export const TimestampValue = z
5
+ // Stryker restore all
4
6
  .number(TimestampValueError.Invalid)
5
7
  .int(TimestampValueError.Invalid)
6
8
  .gte(0, TimestampValueError.Invalid)
@@ -5,5 +5,5 @@ export declare const TimezoneError: {
5
5
  TooLong: string;
6
6
  Invalid: string;
7
7
  };
8
- export declare const Timezone: z.core.$ZodBranded<z.ZodString, "Timezone">;
8
+ export declare const Timezone: z.core.$ZodBranded<z.ZodString, "Timezone", "out">;
9
9
  export type TimezoneType = z.infer<typeof Timezone>;
@@ -5,7 +5,9 @@ export const TimezoneError = {
5
5
  TooLong: "timezone.too.long",
6
6
  Invalid: "timezone.invalid",
7
7
  };
8
+ // Stryker disable all
8
9
  export const Timezone = z
10
+ // Stryker restore all
9
11
  .string(TimezoneError.Type)
10
12
  .min(1, TimezoneError.Empty)
11
13
  .max(128, TimezoneError.TooLong)
@@ -2,5 +2,5 @@ import { z } from "zod/v4";
2
2
  export declare const UrlWithSlashError: {
3
3
  Invalid: string;
4
4
  };
5
- export declare const UrlWithSlash: z.core.$ZodBranded<z.ZodURL, "UrlWithSlash">;
5
+ export declare const UrlWithSlash: z.core.$ZodBranded<z.ZodURL, "UrlWithSlash", "out">;
6
6
  export type UrlWithSlashType = z.infer<typeof UrlWithSlash>;
@@ -1,6 +1,8 @@
1
1
  import { z } from "zod/v4";
2
2
  export const UrlWithSlashError = { Invalid: "url.with.slash.invalid" };
3
+ // Stryker disable all
3
4
  export const UrlWithSlash = z
4
- .url({ error: UrlWithSlashError.Invalid })
5
+ // Stryker disable all
6
+ .url(UrlWithSlashError.Invalid)
5
7
  .refine((value) => value.endsWith("/"), UrlWithSlashError.Invalid)
6
8
  .brand("UrlWithSlash");
@@ -2,5 +2,5 @@ import { z } from "zod/v4";
2
2
  export declare const UrlWithoutSlashError: {
3
3
  Invalid: string;
4
4
  };
5
- export declare const UrlWithoutSlash: z.core.$ZodBranded<z.ZodURL, "UrlWithoutSlash">;
5
+ export declare const UrlWithoutSlash: z.core.$ZodBranded<z.ZodURL, "UrlWithoutSlash", "out">;
6
6
  export type UrlWithoutSlashType = z.infer<typeof UrlWithoutSlash>;
@@ -1,6 +1,8 @@
1
1
  import { z } from "zod/v4";
2
2
  export const UrlWithoutSlashError = { Invalid: "url.without.slash.invalid" };
3
+ // Stryker disable all
3
4
  export const UrlWithoutSlash = z
4
- .url({ error: UrlWithoutSlashError.Invalid })
5
+ // Stryker restore all
6
+ .url(UrlWithoutSlashError.Invalid)
5
7
  .refine((value) => !value.endsWith("/"), UrlWithoutSlashError.Invalid)
6
8
  .brand("UrlWithoutSlash");
@@ -4,5 +4,5 @@ export declare const WeekIsoIdError: {
4
4
  BadChars: string;
5
5
  Invalid: string;
6
6
  };
7
- export declare const WeekIsoId: z.core.$ZodBranded<z.ZodString, "WeekIsoId">;
7
+ export declare const WeekIsoId: z.core.$ZodBranded<z.ZodString, "WeekIsoId", "out">;
8
8
  export type WeekIsoIdType = z.infer<typeof WeekIsoId>;
@@ -7,7 +7,9 @@ export const WeekIsoIdError = {
7
7
  };
8
8
  // Four digits, hypen, W, followed by two digits
9
9
  const WEEK_ISO_ID_CHARS_WHITELIST = /^[0-9]{4}-W[0-9]{2}$/;
10
+ // Stryker disable all
10
11
  export const WeekIsoId = z
12
+ // Stryker restore all
11
13
  .string(WeekIsoIdError.Type)
12
14
  .regex(WEEK_ISO_ID_CHARS_WHITELIST, WeekIsoIdError.BadChars)
13
15
  .refine((value) => {
@@ -7,7 +7,9 @@ export declare enum WeekdayFormatterEnum {
7
7
  ISO_NUMBER = "ISO_NUMBER",// Monday=1 ... Sunday=7
8
8
  ZERO_BASED_NUMBER = "ZERO_BASED_NUMBER"
9
9
  }
10
- export declare const WeekdayValueError: "invalid.weekday";
10
+ export declare const WeekdayValueError: {
11
+ readonly Invalid: "weekday.invalid";
12
+ };
11
13
  export declare const WeekdayFormatters: Record<WeekdayFormatterEnum, WeekdayFormatter>;
12
14
  export declare class Weekday {
13
15
  private readonly value;
@@ -6,7 +6,7 @@ export var WeekdayFormatterEnum;
6
6
  WeekdayFormatterEnum["ISO_NUMBER"] = "ISO_NUMBER";
7
7
  WeekdayFormatterEnum["ZERO_BASED_NUMBER"] = "ZERO_BASED_NUMBER";
8
8
  })(WeekdayFormatterEnum || (WeekdayFormatterEnum = {}));
9
- export const WeekdayValueError = "invalid.weekday";
9
+ export const WeekdayValueError = { Invalid: "weekday.invalid" };
10
10
  const FULL_NAMES = [
11
11
  "Sunday",
12
12
  "Monday",
@@ -36,8 +36,9 @@ export class Weekday {
36
36
  static FRIDAY = new Weekday(5);
37
37
  static SATURDAY = new Weekday(6);
38
38
  constructor(candidate, formatter) {
39
- if (!Number.isInteger(candidate) || candidate < 0 || candidate > 6)
40
- throw new Error(WeekdayValueError);
39
+ if (!Number.isInteger(candidate) || candidate < 0 || candidate > 6) {
40
+ throw new Error(WeekdayValueError.Invalid);
41
+ }
41
42
  this.value = candidate;
42
43
  this.formatter = formatter ?? WeekdayFormatters.FULL;
43
44
  }
@@ -3,5 +3,5 @@ export declare const WeightGramsError: {
3
3
  Type: string;
4
4
  Invalid: string;
5
5
  };
6
- export declare const WeightGrams: z.core.$ZodBranded<z.ZodNumber, "WeightGrams">;
6
+ export declare const WeightGrams: z.core.$ZodBranded<z.ZodNumber, "WeightGrams", "out">;
7
7
  export type WeightGramsType = z.infer<typeof WeightGrams>;
@@ -1,6 +1,8 @@
1
1
  import { z } from "zod/v4";
2
2
  export const WeightGramsError = { Type: "weight.grams.type", Invalid: "weight.grams.invalid" };
3
+ // Stryker disable all
3
4
  export const WeightGrams = z
5
+ // Stryker restore all
4
6
  .number(WeightGramsError.Type)
5
7
  .int(WeightGramsError.Type)
6
8
  .gte(0, WeightGramsError.Invalid)
@@ -18,9 +18,7 @@ export declare class Weight {
18
18
  divide(divisor: DivisionFactorType): Weight;
19
19
  equals(other: Weight): boolean;
20
20
  greaterThan(other: Weight): boolean;
21
- greaterThanOrEqual(other: Weight): boolean;
22
21
  lessThan(other: Weight): boolean;
23
- lessThanOrEqual(other: Weight): boolean;
24
22
  isZero(): boolean;
25
23
  toString(): string;
26
24
  toJSON(): number;
package/dist/weight.vo.js CHANGED
@@ -33,7 +33,7 @@ export class Weight {
33
33
  }
34
34
  subtract(other) {
35
35
  const result = this.grams - other.grams;
36
- return new Weight(WeightGrams.parse(result < 0 ? 0 : result));
36
+ return new Weight(WeightGrams.parse(Math.max(0, result)), this.rounding);
37
37
  }
38
38
  multiply(factor) {
39
39
  const grams = this.rounding.round(this.grams * factor);
@@ -49,15 +49,9 @@ export class Weight {
49
49
  greaterThan(other) {
50
50
  return this.grams > other.grams;
51
51
  }
52
- greaterThanOrEqual(other) {
53
- return this.grams >= other.grams;
54
- }
55
52
  lessThan(other) {
56
53
  return this.grams < other.grams;
57
54
  }
58
- lessThanOrEqual(other) {
59
- return this.grams <= other.grams;
60
- }
61
55
  isZero() {
62
56
  return this.grams === 0;
63
57
  }
@@ -3,5 +3,5 @@ export declare const YearIsoIdError: {
3
3
  Type: string;
4
4
  BadChars: string;
5
5
  };
6
- export declare const YearIsoId: z.core.$ZodBranded<z.ZodString, "YearIsoId">;
6
+ export declare const YearIsoId: z.core.$ZodBranded<z.ZodString, "YearIsoId", "out">;
7
7
  export type YearIsoIdType = z.infer<typeof YearIsoId>;
@@ -2,7 +2,9 @@ import { z } from "zod/v4";
2
2
  export const YearIsoIdError = { Type: "year.iso.id.type", BadChars: "year.iso.id.bad.chars" };
3
3
  // Four digits
4
4
  const YEAR_ISO_ID_CHARS_WHITELIST = /^[0-9]{4}$/;
5
+ // Stryker disable all
5
6
  export const YearIsoId = z
7
+ // Stryker restore all
6
8
  .string(YearIsoIdError.Type)
7
9
  .regex(YEAR_ISO_ID_CHARS_WHITELIST, YearIsoIdError.BadChars)
8
10
  .brand("YearIsoId");
package/dist/year.vo.js CHANGED
@@ -27,7 +27,11 @@ export class Year extends DateRange {
27
27
  }
28
28
  isLeapYear() {
29
29
  const year = getYear(this.getStart().ms);
30
- return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
30
+ if (year % 400 === 0)
31
+ return true;
32
+ if (year % 100 === 0)
33
+ return false;
34
+ return year % 4 === 0;
31
35
  }
32
36
  previous() {
33
37
  return this.shift(Integer.parse(-1));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bgord/tools",
3
- "version": "1.2.12",
3
+ "version": "1.2.14",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Bartosz Gordon",
@@ -24,6 +24,7 @@
24
24
  "@biomejs/biome": "2.3.10",
25
25
  "@commitlint/cli": "20.2.0",
26
26
  "@commitlint/config-conventional": "20.2.0",
27
+ "@stryker-mutator/core": "9.4.0",
27
28
  "@types/bun": "1.3.5",
28
29
  "@types/mime-types": "3.0.1",
29
30
  "cspell": "9.4.0",
@@ -33,14 +34,14 @@
33
34
  "only-allow": "1.2.2",
34
35
  "shellcheck": "4.1.0",
35
36
  "typescript": "5.9.3",
36
- "zod": "4.2.1"
37
+ "zod": "4.3.2"
37
38
  },
38
39
  "dependencies": {
39
40
  "date-fns": "4.1.0",
40
41
  "mime-types": "3.0.2"
41
42
  },
42
43
  "peerDependencies": {
43
- "zod": "4.2.1"
44
+ "zod": "4.3.2"
44
45
  },
45
46
  "sideEffects": false
46
47
  }
@@ -4,7 +4,9 @@ export const AgeYearsError = { Type: "age.years.type", Invalid: "age.years.inval
4
4
 
5
5
  export const AgeYearsConstraints = { min: 1, max: 130 };
6
6
 
7
+ // Stryker disable all
7
8
  export const AgeYears = z
9
+ // Stryker restore all
8
10
  .number(AgeYearsError.Type)
9
11
  .int(AgeYearsError.Type)
10
12
  .min(1, AgeYearsError.Invalid)
package/src/api-key.vo.ts CHANGED
@@ -5,7 +5,9 @@ export const ApiKeyError = { Type: "api.key.type", Length: "api.key.length", Bad
5
5
  // 64 letters and digits allowed
6
6
  const API_KEY_CHARS = /^[a-zA-Z0-9]{64}$/;
7
7
 
8
+ // Stryker disable all
8
9
  export const ApiKey = z
10
+ // Stryker disable all
9
11
  .string(ApiKeyError.Type)
10
12
  .length(64, ApiKeyError.Length)
11
13
  .regex(API_KEY_CHARS, ApiKeyError.BadChars)
@@ -15,7 +15,9 @@ const BASENAME_CHARS = /^[a-zA-Z0-9._-]+$/;
15
15
 
16
16
  const DOT_SEGMENTS = [".", ".."];
17
17
 
18
+ // Stryker disable all
18
19
  export const Basename = z
20
+ // Stryker restore all
19
21
  .string(BasenameError.Type)
20
22
  .min(1, BasenameError.Empty)
21
23
  .max(128, BasenameError.TooLong)
@@ -10,7 +10,9 @@ export const DayIsoIdError = {
10
10
  // Four digits, hyphen, two digits, hyphen, two digits
11
11
  export const DAY_ISO_ID_CHARS = /^[0-9]{4}-[0-9]{2}-[0-9]{2}$/;
12
12
 
13
+ // Stryker disable all
13
14
  export const DayIsoId = z
15
+ // Stryker restore all
14
16
  .string(DayIsoIdError.Type)
15
17
  .regex(DAY_ISO_ID_CHARS, DayIsoIdError.BadChars)
16
18
  .refine((value) => isValid(parseISO(value)), DayIsoIdError.InvalidDate)
@@ -14,7 +14,9 @@ export const DIRECTORY_PATH_ABSOLUTE_CHARS = /^[a-zA-Z0-9._-]+$/;
14
14
 
15
15
  const DOT_SEGMENTS = [".", ".."];
16
16
 
17
+ // Stryker disable all
17
18
  export const DirectoryPathAbsoluteSchema = z
19
+ // Stryker restore all
18
20
  .string(DirectoryPathAbsoluteError.Type)
19
21
  .min(1, DirectoryPathAbsoluteError.Empty)
20
22
  .max(512, DirectoryPathAbsoluteError.TooLong)
@@ -6,7 +6,7 @@ export const DirectoryPathRelativeError = {
6
6
  LeadingSlash: "directory.path.relative.leading.slash",
7
7
  TooLong: "directory.path.absolue.too.long",
8
8
  TrailingSlash: "directory.path.absolue.trailing.slash",
9
- Type: "directory.path.relative.not.type",
9
+ Type: "directory.path.relative.type",
10
10
  };
11
11
 
12
12
  // Letters, digits, dots, underscores, and hyphens
@@ -14,7 +14,9 @@ export const DIRECTORY_PATH_RELATIVE_CHARS = /^[A-Za-z0-9._-]+$/;
14
14
 
15
15
  const DOT_SEGMENTS = [".", ".."];
16
16
 
17
+ // Stryker disable all
17
18
  export const DirectoryPathRelativeSchema = z
19
+ // Stryker restore all
18
20
  .string(DirectoryPathRelativeError.Type)
19
21
  .min(1, DirectoryPathRelativeError.Empty)
20
22
  .max(512, DirectoryPathRelativeError.TooLong)
@@ -2,7 +2,9 @@ import { z } from "zod/v4";
2
2
 
3
3
  export const DistanceValueError = { Type: "distance.value.type", Invalid: "distance.value.invalid" };
4
4
 
5
+ // Stryker disable all
5
6
  export const DistanceValue = z
7
+ // Stryker restore all
6
8
  .number(DistanceValueError.Type)
7
9
  .int(DistanceValueError.Type)
8
10
  .min(0, DistanceValueError.Invalid)
@@ -2,7 +2,9 @@ import { z } from "zod/v4";
2
2
 
3
3
  export const DivisionFactorError = { Type: "division.factor.type", Invalid: "division.factor.invalid" };
4
4
 
5
+ // Stryker disable all
5
6
  export const DivisionFactor = z
7
+ // Stryker restore all
6
8
  .number(DivisionFactorError.Type)
7
9
  .gt(0, DivisionFactorError.Invalid)
8
10
  .brand("DivisionFactor");
@@ -108,15 +108,13 @@ export class DoublyLinkedList<T> {
108
108
  return;
109
109
  }
110
110
 
111
- const nextNode = target.next;
111
+ const nextNode = target.next!;
112
112
  this.size += 1;
113
113
 
114
114
  node.prev = target;
115
115
  node.next = nextNode;
116
116
 
117
- if (nextNode) {
118
- nextNode.prev = node;
119
- }
117
+ nextNode.prev = node;
120
118
 
121
119
  target.next = node;
122
120
  }
@@ -127,15 +125,13 @@ export class DoublyLinkedList<T> {
127
125
  return;
128
126
  }
129
127
 
130
- const prevNode = target.prev;
128
+ const prevNode = target.prev!;
131
129
  this.size += 1;
132
130
 
133
131
  node.next = target;
134
132
  node.prev = prevNode;
135
133
 
136
- if (prevNode) {
137
- prevNode.next = node;
138
- }
134
+ prevNode.next = node;
139
135
 
140
136
  target.prev = node;
141
137
  }
@@ -2,6 +2,8 @@ import { z } from "zod/v4";
2
2
 
3
3
  export const DurationMsError = { Invalid: "duration.invalid" };
4
4
 
5
+ // Stryker disable all
5
6
  export const DurationMs = z.number(DurationMsError.Invalid).int(DurationMsError.Invalid).brand("DurationMs");
7
+ // Stryker restore all
6
8
 
7
9
  export type DurationMsType = z.infer<typeof DurationMs>;
package/src/email.vo.ts CHANGED
@@ -2,6 +2,8 @@ import { z } from "zod/v4";
2
2
 
3
3
  export const EmailError = { Invalid: "email.invalid" };
4
4
 
5
+ // Stryker disable all
5
6
  export const Email = z.email({ error: EmailError.Invalid }).brand("Email");
7
+ // Stryker restore all
6
8
 
7
9
  export type EmailType = z.infer<typeof Email>;
package/src/etags.vo.ts CHANGED
@@ -14,8 +14,6 @@ export class ETag {
14
14
  }
15
15
 
16
16
  static fromHeader(value?: ETagValueType): ETag | null {
17
- if (value?.startsWith("W/")) return null;
18
-
19
17
  const candidate = Number(value);
20
18
 
21
19
  if (Number.isNaN(candidate)) return null;
@@ -12,7 +12,9 @@ const EXTENSION_WHITELIST = /^[a-z0-9]+$/;
12
12
 
13
13
  const LEADING_DOT_FILE = /^\./;
14
14
 
15
+ // Stryker disable all
15
16
  export const Extension = z
17
+ // Stryker restore all
16
18
  .string(ExtensionError.Type)
17
19
  .toLowerCase()
18
20
  .min(2, ExtensionError.Empty)
@@ -10,7 +10,9 @@ export const FilePathAbsoluteSchemaError = {
10
10
  Empty: "file.path.absolute.empty",
11
11
  };
12
12
 
13
+ // Stryker disable all
13
14
  export const FilePathAbsoluteSchema = z
15
+ // Stryker restore all
14
16
  .string(FilePathAbsoluteSchemaError.Type)
15
17
  .min(1, FilePathAbsoluteSchemaError.Empty)
16
18
  .refine((value) => value.startsWith("/"), FilePathAbsoluteSchemaError.LeadingSlash)
@@ -10,7 +10,9 @@ export const FilePathRelativeSchemaError = {
10
10
  Empty: "file.path.relative.empty",
11
11
  };
12
12
 
13
+ // Stryker disable all
13
14
  export const FilePathRelativeSchema = z
15
+ // Stryker restore all
14
16
  .string(FilePathRelativeSchemaError.Type)
15
17
  .min(1, FilePathRelativeSchemaError.Empty)
16
18
  .refine((value) => !value.startsWith("/"), FilePathRelativeSchemaError.LeadingSlash)
@@ -15,7 +15,9 @@ export const FilenameAffixError = {
15
15
  // Letters, digits, underscores, and hyphens allowed
16
16
  const FILENAME_AFFIX_WHITELIST = /^[a-zA-Z0-9_-]+$/;
17
17
 
18
+ // Stryker disable all
18
19
  export const FilenameAffix = z
20
+ // Stryker restore all
19
21
  .string(FilenameAffixError.Type)
20
22
  .min(1, FilenameAffixError.Empty)
21
23
  .max(32, FilenameAffixError.TooLong)
@@ -5,7 +5,9 @@ export const HeightMillimetersError = {
5
5
  Invalid: "height.millimeters.invalid",
6
6
  };
7
7
 
8
+ // Stryker disable all
8
9
  export const HeightMillimeters = z
10
+ // Stryker restore all
9
11
  .number(HeightMillimetersError.Type)
10
12
  .int(HeightMillimetersError.Type)
11
13
  .min(0, HeightMillimetersError.Invalid)
@@ -1,8 +1,10 @@
1
1
  import { z } from "zod/v4";
2
2
 
3
- export const HourSchemaError = { Type: "hour.schema.error", Invalid: "hour.schema.invalid" };
3
+ export const HourSchemaError = { Type: "hour.schema.type", Invalid: "hour.schema.invalid" };
4
4
 
5
+ // Stryker disable all
5
6
  export const HourSchema = z
7
+ // Stryker restore all
6
8
  .number(HourSchemaError.Type)
7
9
  .int(HourSchemaError.Type)
8
10
  .gte(0, HourSchemaError.Invalid)
@@ -5,7 +5,9 @@ export const IbanSchemaError = { Type: "iban.schema.type", Invalid: "iban.schema
5
5
  // Two letters for country code, two digits, 11–30 uppercase letters or digits
6
6
  const IBAN_CHARS_WHITELIST = /^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$/;
7
7
 
8
+ // Stryker disable all
8
9
  export const IbanSchema = z
10
+ // Stryker restore all
9
11
  .string(IbanSchemaError.Type)
10
12
  .toUpperCase()
11
13
  .transform((value) => value.replaceAll(" ", ""))