@bgord/tools 1.4.1 → 1.4.2

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,6 +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
+ import type { IntegerType } from "./integer.vo";
4
4
  import { Timestamp } from "./timestamp.vo";
5
5
  import type { TimestampValueType } from "./timestamp-value.vo";
6
6
  export declare class Day extends DateRange {
package/dist/day.vo.js CHANGED
@@ -3,7 +3,7 @@ import * as v from "valibot";
3
3
  import { DateRange } from "./date-range.vo";
4
4
  import { DayIsoId } from "./day-iso-id.vo";
5
5
  import { Duration } from "./duration.service";
6
- import { Integer } from "./integer.vo";
6
+ import { Int } from "./int.vo";
7
7
  import { Timestamp } from "./timestamp.vo";
8
8
  export class Day extends DateRange {
9
9
  static fromTimestamp(timestamp) {
@@ -29,10 +29,10 @@ export class Day extends DateRange {
29
29
  return v.parse(DayIsoId, formatISO(midday.ms, { representation: "date" }));
30
30
  }
31
31
  previous() {
32
- return this.shift(v.parse(Integer, -1));
32
+ return this.shift(Int.of(-1));
33
33
  }
34
34
  next() {
35
- return this.shift(v.parse(Integer, 1));
35
+ return this.shift(Int.of(1));
36
36
  }
37
37
  shift(count) {
38
38
  return Day.fromTimestamp(this.getStart().add(Duration.Days(count)));
package/dist/index.d.ts CHANGED
@@ -37,6 +37,7 @@ export * from "./iban-mask.service";
37
37
  export * from "./iban-schema.vo";
38
38
  export * from "./image.vo";
39
39
  export * from "./index";
40
+ export * from "./int.vo";
40
41
  export * from "./integer.vo";
41
42
  export * from "./integer-non-negative.vo";
42
43
  export * from "./integer-positive.vo";
package/dist/index.js CHANGED
@@ -37,6 +37,7 @@ export * from "./iban-mask.service";
37
37
  export * from "./iban-schema.vo";
38
38
  export * from "./image.vo";
39
39
  export * from "./index";
40
+ export * from "./int.vo";
40
41
  export * from "./integer.vo";
41
42
  export * from "./integer-non-negative.vo";
42
43
  export * from "./integer-positive.vo";
@@ -0,0 +1,8 @@
1
+ import { type IntegerType } from "./integer.vo";
2
+ import { type IntegerNonNegativeType } from "./integer-non-negative.vo";
3
+ import { type IntegerPositiveType } from "./integer-positive.vo";
4
+ export declare class Int {
5
+ static positive(candidate: number): IntegerPositiveType;
6
+ static nonNegative(candidate: number): IntegerNonNegativeType;
7
+ static of(candidate: number): IntegerType;
8
+ }
package/dist/int.vo.js ADDED
@@ -0,0 +1,15 @@
1
+ import * as v from "valibot";
2
+ import { Integer } from "./integer.vo";
3
+ import { IntegerNonNegative } from "./integer-non-negative.vo";
4
+ import { IntegerPositive } from "./integer-positive.vo";
5
+ export class Int {
6
+ static positive(candidate) {
7
+ return v.parse(IntegerPositive, candidate);
8
+ }
9
+ static nonNegative(candidate) {
10
+ return v.parse(IntegerNonNegative, candidate);
11
+ }
12
+ static of(candidate) {
13
+ return v.parse(Integer, candidate);
14
+ }
15
+ }
@@ -1,5 +1,5 @@
1
1
  import { DateRange } from "./date-range.vo";
2
- import { type IntegerType } from "./integer.vo";
2
+ import type { IntegerType } from "./integer.vo";
3
3
  import { type MonthIsoIdType } from "./month-iso-id.vo";
4
4
  import { Timestamp } from "./timestamp.vo";
5
5
  import type { TimestampValueType } from "./timestamp-value.vo";
package/dist/month.vo.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { endOfMonth, format, startOfMonth } from "date-fns";
2
2
  import * as v from "valibot";
3
3
  import { DateRange } from "./date-range.vo";
4
- import { Integer } from "./integer.vo";
4
+ import { Int } from "./int.vo";
5
5
  import { MonthIsoId } from "./month-iso-id.vo";
6
6
  import { Timestamp } from "./timestamp.vo";
7
7
  export class Month extends DateRange {
@@ -25,10 +25,10 @@ export class Month extends DateRange {
25
25
  return v.parse(MonthIsoId, format(this.getStart().ms, "yyyy-MM"));
26
26
  }
27
27
  previous() {
28
- return this.shift(v.parse(Integer, -1));
28
+ return this.shift(Int.of(-1));
29
29
  }
30
30
  next() {
31
- return this.shift(v.parse(Integer, 1));
31
+ return this.shift(Int.of(1));
32
32
  }
33
33
  shift(count) {
34
34
  const start = new Date(this.getStart().ms);
@@ -1 +1 @@
1
- {"root":["../src/age-years.vo.ts","../src/age.vo.ts","../src/api-key.vo.ts","../src/basename.vo.ts","../src/batch.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-value.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-value.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/repeat.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"}
1
+ {"root":["../src/age-years.vo.ts","../src/age.vo.ts","../src/api-key.vo.ts","../src/basename.vo.ts","../src/batch.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-value.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/int.vo.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-value.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/repeat.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"}
package/dist/week.vo.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { DateRange } from "./date-range.vo";
2
- import { type IntegerType } from "./integer.vo";
2
+ import type { IntegerType } from "./integer.vo";
3
3
  import { Timestamp } from "./timestamp.vo";
4
4
  import type { TimestampValueType } from "./timestamp-value.vo";
5
5
  import { type WeekIsoIdType } from "./week-iso-id.vo";
package/dist/week.vo.js CHANGED
@@ -2,7 +2,7 @@ import { addWeeks, endOfISOWeek, getISOWeek, getISOWeekYear, startOfISOWeek } fr
2
2
  import * as v from "valibot";
3
3
  import { DateRange } from "./date-range.vo";
4
4
  import { Duration } from "./duration.service";
5
- import { Integer } from "./integer.vo";
5
+ import { Int } from "./int.vo";
6
6
  import { Timestamp } from "./timestamp.vo";
7
7
  import { WeekIsoId } from "./week-iso-id.vo";
8
8
  export class Week extends DateRange {
@@ -30,10 +30,10 @@ export class Week extends DateRange {
30
30
  return v.parse(WeekIsoId, `${year}-W${String(week).padStart(2, "0")}`);
31
31
  }
32
32
  previous() {
33
- return this.shift(v.parse(Integer, -1));
33
+ return this.shift(Int.of(-1));
34
34
  }
35
35
  next() {
36
- return this.shift(v.parse(Integer, 1));
36
+ return this.shift(Int.of(1));
37
37
  }
38
38
  shift(count) {
39
39
  const shifted = addWeeks(this.getStart().ms, count).getTime();
package/dist/year.vo.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { DateRange } from "./date-range.vo";
2
- import { type IntegerType } from "./integer.vo";
2
+ import type { IntegerType } from "./integer.vo";
3
3
  import { Timestamp } from "./timestamp.vo";
4
4
  import type { TimestampValueType } from "./timestamp-value.vo";
5
5
  import { type YearIsoIdType } from "./year-iso-id.vo";
package/dist/year.vo.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { endOfYear, getYear, startOfYear } from "date-fns";
2
2
  import * as v from "valibot";
3
3
  import { DateRange } from "./date-range.vo";
4
- import { Integer } from "./integer.vo";
4
+ import { Int } from "./int.vo";
5
5
  import { Timestamp } from "./timestamp.vo";
6
6
  import { YearIsoId } from "./year-iso-id.vo";
7
7
  export class Year extends DateRange {
@@ -35,10 +35,10 @@ export class Year extends DateRange {
35
35
  return year % 4 === 0;
36
36
  }
37
37
  previous() {
38
- return this.shift(v.parse(Integer, -1));
38
+ return this.shift(Int.of(-1));
39
39
  }
40
40
  next() {
41
- return this.shift(v.parse(Integer, 1));
41
+ return this.shift(Int.of(1));
42
42
  }
43
43
  shift(count) {
44
44
  const year = getYear(this.getStart().ms) + count;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bgord/tools",
3
- "version": "1.4.1",
3
+ "version": "1.4.2",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Bartosz Gordon",
@@ -35,7 +35,7 @@
35
35
  },
36
36
  "dependencies": {
37
37
  "date-fns": "4.1.0",
38
- "valibot": "1.2.0"
38
+ "valibot": "1.3.0"
39
39
  },
40
40
  "sideEffects": false
41
41
  }
package/readme.md CHANGED
@@ -62,6 +62,7 @@ src/
62
62
  ├── iban-schema.vo.ts
63
63
  ├── iban.vo.ts
64
64
  ├── image.vo.ts
65
+ ├── int.vo.ts
65
66
  ├── integer-non-negative.vo.ts
66
67
  ├── integer-positive.vo.ts
67
68
  ├── integer.vo.ts