@bgord/tools 0.12.19 → 0.12.22

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.
@@ -1,5 +1,5 @@
1
- import { Hour } from "./hour.vo";
2
- import { Minute } from "./minute.vo";
1
+ import { type Hour } from "./hour.vo";
2
+ import type { Minute } from "./minute.vo";
3
3
  export type ClockFormatter = (hour: Hour, minute: Minute) => string;
4
4
  declare enum ClockFormatterEnum {
5
5
  TWENTY_FOUR_HOURS = "TWENTY_FOUR_HOURS",
@@ -1,4 +1,4 @@
1
- import { TimestampType } from "./timestamp.vo";
1
+ import type { TimestampType } from "./timestamp.vo";
2
2
  export declare class DateRange {
3
3
  private readonly start;
4
4
  private readonly end;
package/dist/day.vo.d.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  import { DateRange } from "./date-range.vo";
2
- import { DayIsoIdType } from "./day-iso-id.vo";
3
- import { TimestampType } from "./timestamp.vo";
2
+ import { type DayIsoIdType } from "./day-iso-id.vo";
3
+ import { type TimestampType } from "./timestamp.vo";
4
4
  export declare class Day extends DateRange {
5
5
  private constructor();
6
6
  toIsoId(): DayIsoIdType;
7
7
  static fromTimestamp(timestamp: TimestampType): Day;
8
- static fromNow(now?: TimestampType): Day;
8
+ static fromNow(now: TimestampType): Day;
9
9
  static fromIsoId(isoId: DayIsoIdType): Day;
10
10
  }
package/dist/day.vo.js CHANGED
@@ -15,7 +15,7 @@ export class Day extends DateRange {
15
15
  const end = Timestamp.parse(endOfDay(timestamp).getTime());
16
16
  return new Day(start, end);
17
17
  }
18
- static fromNow(now = Timestamp.parse(Date.now())) {
18
+ static fromNow(now) {
19
19
  return Day.fromTimestamp(now);
20
20
  }
21
21
  static fromIsoId(isoId) {
@@ -1,4 +1,4 @@
1
- import { z } from "zod/v4";
1
+ import type { z } from "zod/v4";
2
2
  export type DefaultFilterSchemaType = z.ZodRawShape;
3
3
  export type FilterValuesType = Record<string, unknown>;
4
4
  export type FilterSchemaType<T extends DefaultFilterSchemaType> = z.ZodObject<T>;
@@ -1,4 +1,4 @@
1
- import { IBAN } from "./iban.vo";
1
+ import type { IBAN } from "./iban.vo";
2
2
  type IbanMaskedType = string;
3
3
  export declare class IbanMask {
4
4
  static censor(iban: IBAN): IbanMaskedType;
@@ -1,4 +1,4 @@
1
- import { RoundingStrategy } from "./rounding.service";
1
+ import { type RoundingStrategy } from "./rounding.service";
2
2
  export declare class Mean {
3
3
  static calculate(values: number[], rounding?: RoundingStrategy): number;
4
4
  }
@@ -1,4 +1,4 @@
1
- import { RoundingStrategy } from "./rounding.service";
1
+ import { type RoundingStrategy } from "./rounding.service";
2
2
  type MinMaxScalerValueType = number;
3
3
  type MinMaxScalerConfigType = {
4
4
  min: MinMaxScalerValueType;
@@ -1,5 +1,5 @@
1
1
  import { z } from "zod/v4";
2
- import { RoundingStrategy } from "./rounding.service";
2
+ import { type RoundingStrategy } from "./rounding.service";
3
3
  export declare const MoneyAmount: z.core.$ZodBranded<z.ZodNumber, "MoneyAmount">;
4
4
  export type MoneyAmountType = z.infer<typeof MoneyAmount>;
5
5
  export declare const MoneyMultiplicationFactor: z.core.$ZodBranded<z.ZodNumber, "MoneyMultiplicationFactor">;
@@ -1,4 +1,4 @@
1
- import { RoundingStrategy } from "./rounding.service";
1
+ import { type RoundingStrategy } from "./rounding.service";
2
2
  export declare class Percentage {
3
3
  static of(numerator: number, denominator: number, rounding?: RoundingStrategy): number;
4
4
  }
@@ -1,4 +1,4 @@
1
- import { RoundingStrategy } from "./rounding.service";
1
+ import { type RoundingStrategy } from "./rounding.service";
2
2
  export declare class PopulationStandardDeviation {
3
3
  static calculate(values: number[], rounding?: RoundingStrategy): number;
4
4
  }
@@ -1,5 +1,5 @@
1
1
  import type { TimeResult } from "./time.service";
2
- import { TimestampType } from "./timestamp.vo";
2
+ import { type TimestampType } from "./timestamp.vo";
3
3
  type RateLimiterOptionsType = Pick<TimeResult, "ms">;
4
4
  type RateLimiterResultSuccessType = {
5
5
  allowed: true;
@@ -1,5 +1,5 @@
1
1
  import { z } from "zod/v4";
2
- import { ETag, WeakETag } from "./etags.vo";
2
+ import type { ETag, WeakETag } from "./etags.vo";
3
3
  export declare const RevisionValue: z.ZodNumber;
4
4
  export type RevisionValueType = z.infer<typeof RevisionValue>;
5
5
  export declare class Revision {
@@ -1,4 +1,4 @@
1
- import { RoundingStrategy } from "./rounding.service";
1
+ import { type RoundingStrategy } from "./rounding.service";
2
2
  export type SLRPairType = {
3
3
  x: number;
4
4
  y: number;
@@ -1,4 +1,4 @@
1
- import { TimestampType } from "./timestamp.vo";
1
+ import { type TimestampType } from "./timestamp.vo";
2
2
  export type StopwatchResultType = {
3
3
  durationMs: TimestampType;
4
4
  };
@@ -24,8 +24,7 @@ export declare class Time {
24
24
  static Minutes(value: number): TimeResultInterface;
25
25
  static Seconds(value: number): TimeResultInterface;
26
26
  static Ms(value: number): TimeResultInterface;
27
- static Now(now?: number): {
28
- value: TimestampType;
27
+ static Now(now: TimestampType): {
29
28
  Minus(time: TimeResultInterface): TimeResultInterface;
30
29
  Add(time: TimeResultInterface): TimeResultInterface;
31
30
  };
@@ -36,9 +36,8 @@ export class Time {
36
36
  static Ms(value) {
37
37
  return new TimeResult(rounding.round(value / 1000 / 60 / 60 / 24), rounding.round(value / 1000 / 60 / 60), rounding.round(value / 1000 / 60), rounding.round(value / 1000), value);
38
38
  }
39
- static Now(now = Date.now()) {
39
+ static Now(now) {
40
40
  return {
41
- value: now,
42
41
  Minus(time) {
43
42
  return Time.Ms(now - time.ms);
44
43
  },
package/dist/week.vo.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import { DateRange } from "./date-range.vo";
2
- import { TimestampType } from "./timestamp.vo";
3
- import { WeekIsoIdType } from "./week-iso-id.vo";
2
+ import { type TimestampType } from "./timestamp.vo";
3
+ import { type WeekIsoIdType } from "./week-iso-id.vo";
4
4
  export declare class Week extends DateRange {
5
5
  toIsoId(): WeekIsoIdType;
6
6
  static fromTimestamp(timestamp: TimestampType): Week;
7
- static fromNow(now?: TimestampType): Week;
7
+ static fromNow(now: TimestampType): Week;
8
8
  static fromIsoId(isoId: WeekIsoIdType): Week;
9
9
  }
package/dist/week.vo.js CHANGED
@@ -13,7 +13,7 @@ export class Week extends DateRange {
13
13
  const end = Timestamp.parse(endOfISOWeek(timestamp).getTime());
14
14
  return new Week(start, end);
15
15
  }
16
- static fromNow(now = Timestamp.parse(Date.now())) {
16
+ static fromNow(now) {
17
17
  return Week.fromTimestamp(now);
18
18
  }
19
19
  static fromIsoId(isoId) {
@@ -1,4 +1,4 @@
1
- import { RoundingStrategy } from "./rounding.service";
1
+ import { type RoundingStrategy } from "./rounding.service";
2
2
  export declare class ZScore {
3
3
  private readonly rounding;
4
4
  private readonly mean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bgord/tools",
3
- "version": "0.12.19",
3
+ "version": "0.12.22",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Bartosz Gordon",
@@ -25,21 +25,21 @@
25
25
  "@commitlint/cli": "19.8.1",
26
26
  "@commitlint/config-conventional": "19.8.1",
27
27
  "@types/bun": "1.2.21",
28
- "@types/mime-types": "^3.0.1",
28
+ "@types/mime-types": "3.0.1",
29
29
  "cspell": "9.2.0",
30
30
  "knip": "5.63.0",
31
31
  "lefthook": "1.12.3",
32
32
  "only-allow": "1.2.1",
33
33
  "shellcheck": "4.1.0",
34
34
  "typescript": "5.9.2",
35
- "zod": "4.1.4"
35
+ "zod": "4.1.5"
36
36
  },
37
37
  "dependencies": {
38
38
  "date-fns": "4.1.0",
39
- "mime-types": "^3.0.1"
39
+ "mime-types": "3.0.1"
40
40
  },
41
41
  "peerDependencies": {
42
- "zod": "4.1.4"
42
+ "zod": "4.1.5"
43
43
  },
44
44
  "sideEffects": false
45
45
  }
package/src/clock.vo.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { Hour, HourFormatters } from "./hour.vo";
2
- import { Minute } from "./minute.vo";
1
+ import { type Hour, HourFormatters } from "./hour.vo";
2
+ import type { Minute } from "./minute.vo";
3
3
 
4
4
  export type ClockFormatter = (hour: Hour, minute: Minute) => string;
5
5
 
@@ -1,4 +1,4 @@
1
- import { TimestampType } from "./timestamp.vo";
1
+ import type { TimestampType } from "./timestamp.vo";
2
2
 
3
3
  export class DateRange {
4
4
  constructor(
package/src/day.vo.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { endOfDay, startOfDay } from "date-fns";
2
2
  import { DateRange } from "./date-range.vo";
3
- import { DayIsoId, DayIsoIdType } from "./day-iso-id.vo";
3
+ import { DayIsoId, type DayIsoIdType } from "./day-iso-id.vo";
4
4
  import { Time } from "./time.service";
5
- import { Timestamp, TimestampType } from "./timestamp.vo";
5
+ import { Timestamp, type TimestampType } from "./timestamp.vo";
6
6
 
7
7
  export class Day extends DateRange {
8
8
  private constructor(start: TimestampType, end: TimestampType) {
@@ -19,7 +19,7 @@ export class Day extends DateRange {
19
19
  return new Day(start, end);
20
20
  }
21
21
 
22
- static fromNow(now: TimestampType = Timestamp.parse(Date.now())): Day {
22
+ static fromNow(now: TimestampType): Day {
23
23
  return Day.fromTimestamp(now);
24
24
  }
25
25
 
package/src/filter.vo.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { z } from "zod/v4";
1
+ import type { z } from "zod/v4";
2
2
 
3
3
  export type DefaultFilterSchemaType = z.ZodRawShape;
4
4
 
@@ -1,4 +1,4 @@
1
- import { IBAN } from "./iban.vo";
1
+ import type { IBAN } from "./iban.vo";
2
2
 
3
3
  type IbanMaskedType = string;
4
4
 
@@ -1,4 +1,4 @@
1
- import { RoundingStrategy, RoundToDecimal } from "./rounding.service";
1
+ import { type RoundingStrategy, RoundToDecimal } from "./rounding.service";
2
2
  import { Sum } from "./sum.service";
3
3
 
4
4
  export class Mean {
@@ -1,4 +1,4 @@
1
- import { RoundingStrategy, RoundToDecimal } from "./rounding.service";
1
+ import { type RoundingStrategy, RoundToDecimal } from "./rounding.service";
2
2
 
3
3
  type MinMaxScalerValueType = number;
4
4
 
package/src/money.vo.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { z } from "zod/v4";
2
- import { RoundingStrategy, RoundToNearest } from "./rounding.service";
2
+ import { type RoundingStrategy, RoundToNearest } from "./rounding.service";
3
3
 
4
4
  export const MoneyAmount = z
5
5
  .number()
@@ -1,4 +1,4 @@
1
- import { RoundingStrategy, RoundToNearest } from "./rounding.service";
1
+ import { type RoundingStrategy, RoundToNearest } from "./rounding.service";
2
2
 
3
3
  export class Percentage {
4
4
  static of(
@@ -1,5 +1,5 @@
1
1
  import { Mean } from "./mean.service";
2
- import { RoundingStrategy, RoundToDecimal } from "./rounding.service";
2
+ import { type RoundingStrategy, RoundToDecimal } from "./rounding.service";
3
3
  import { Sum } from "./sum.service";
4
4
 
5
5
  export class PopulationStandardDeviation {
@@ -1,5 +1,5 @@
1
1
  import type { TimeResult } from "./time.service";
2
- import { Timestamp, TimestampType } from "./timestamp.vo";
2
+ import { Timestamp, type TimestampType } from "./timestamp.vo";
3
3
  import type { Falsy } from "./ts-utils";
4
4
 
5
5
  type RateLimiterOptionsType = Pick<TimeResult, "ms">;
@@ -1,5 +1,5 @@
1
1
  import { z } from "zod/v4";
2
- import { ETag, WeakETag } from "./etags.vo";
2
+ import type { ETag, WeakETag } from "./etags.vo";
3
3
 
4
4
  export const RevisionValue = z.number().int().min(0);
5
5
 
@@ -1,4 +1,4 @@
1
- import { RoundingStrategy, RoundToNearest } from "./rounding.service";
1
+ import { type RoundingStrategy, RoundToNearest } from "./rounding.service";
2
2
  import { Sum } from "./sum.service";
3
3
 
4
4
  export type SLRPairType = { x: number; y: number };
@@ -1,4 +1,4 @@
1
- import { Timestamp, TimestampType } from "./timestamp.vo";
1
+ import { Timestamp, type TimestampType } from "./timestamp.vo";
2
2
  import type { Falsy } from "./ts-utils";
3
3
 
4
4
  enum StopwatchState {
@@ -83,10 +83,8 @@ export class Time {
83
83
  );
84
84
  }
85
85
 
86
- static Now(now = Date.now()) {
86
+ static Now(now: TimestampType) {
87
87
  return {
88
- value: now as TimestampType,
89
-
90
88
  Minus(time: TimeResultInterface): TimeResultInterface {
91
89
  return Time.Ms(now - time.ms);
92
90
  },
package/src/week.vo.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { endOfISOWeek, getISOWeek, getISOWeekYear, setISOWeek, startOfISOWeek } from "date-fns";
2
2
  import { DateRange } from "./date-range.vo";
3
- import { Timestamp, TimestampType } from "./timestamp.vo";
4
- import { WeekIsoId, WeekIsoIdType } from "./week-iso-id.vo";
3
+ import { Timestamp, type TimestampType } from "./timestamp.vo";
4
+ import { WeekIsoId, type WeekIsoIdType } from "./week-iso-id.vo";
5
5
 
6
6
  export class Week extends DateRange {
7
7
  toIsoId(): WeekIsoIdType {
@@ -18,7 +18,7 @@ export class Week extends DateRange {
18
18
  return new Week(start, end);
19
19
  }
20
20
 
21
- static fromNow(now: TimestampType = Timestamp.parse(Date.now())): Week {
21
+ static fromNow(now: TimestampType): Week {
22
22
  return Week.fromTimestamp(now);
23
23
  }
24
24
 
@@ -1,6 +1,6 @@
1
1
  import { Mean } from "./mean.service";
2
2
  import { PopulationStandardDeviation } from "./population-standard-deviation.service";
3
- import { RoundingStrategy, RoundToDecimal } from "./rounding.service";
3
+ import { type RoundingStrategy, RoundToDecimal } from "./rounding.service";
4
4
 
5
5
  export class ZScore {
6
6
  private readonly mean: number;