@bgord/tools 0.9.0 → 0.9.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/iban.vo.d.ts +2 -2
- package/dist/iban.vo.js +1 -1
- package/dist/rate-limiter.service.d.ts +2 -3
- package/dist/size.vo.d.ts +2 -2
- package/dist/size.vo.js +7 -7
- package/dist/timestamp.vo.js +1 -1
- package/package.json +1 -1
- package/src/iban.vo.ts +1 -1
- package/src/rate-limiter.service.ts +2 -1
- package/src/size.vo.ts +9 -9
- package/src/timestamp.vo.ts +1 -1
package/dist/iban.vo.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
declare const IBANValueSchema: z.
|
|
1
|
+
import { z } from "zod/v4";
|
|
2
|
+
declare const IBANValueSchema: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
3
3
|
type IBANValueType = z.infer<typeof IBANValueSchema>;
|
|
4
4
|
type IBANCountryCode = string;
|
|
5
5
|
export declare class IBAN {
|
package/dist/iban.vo.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
+
import type { TimeResult } from "./time.service";
|
|
1
2
|
import { TimestampType } from "./timestamp.vo";
|
|
2
|
-
type RateLimiterOptionsType =
|
|
3
|
-
ms: TimestampType;
|
|
4
|
-
};
|
|
3
|
+
type RateLimiterOptionsType = Pick<TimeResult, "ms">;
|
|
5
4
|
type RateLimiterResultSuccessType = {
|
|
6
5
|
allowed: true;
|
|
7
6
|
};
|
package/dist/size.vo.d.ts
CHANGED
|
@@ -6,10 +6,10 @@ export declare enum SizeUnit {
|
|
|
6
6
|
GB = "GB"
|
|
7
7
|
}
|
|
8
8
|
declare const SizeValue: z.core.$ZodBranded<z.ZodNumber, "SizeValue">;
|
|
9
|
-
|
|
9
|
+
type SizeValueType = z.infer<typeof SizeValue>;
|
|
10
10
|
type SizeConfigType = {
|
|
11
11
|
unit: SizeUnit;
|
|
12
|
-
value:
|
|
12
|
+
value: number;
|
|
13
13
|
};
|
|
14
14
|
export declare class Size {
|
|
15
15
|
private readonly unit;
|
package/dist/size.vo.js
CHANGED
|
@@ -18,7 +18,7 @@ export class Size {
|
|
|
18
18
|
constructor(config) {
|
|
19
19
|
this.unit = config.unit;
|
|
20
20
|
this.value = SizeValue.parse(config.value);
|
|
21
|
-
this.bytes = this.calculateBytes(
|
|
21
|
+
this.bytes = this.calculateBytes();
|
|
22
22
|
}
|
|
23
23
|
toString() {
|
|
24
24
|
return `${this.value} ${this.unit}`;
|
|
@@ -54,17 +54,17 @@ export class Size {
|
|
|
54
54
|
return new Size(config).toBytes();
|
|
55
55
|
}
|
|
56
56
|
static unit = SizeUnit;
|
|
57
|
-
calculateBytes(
|
|
58
|
-
switch (
|
|
57
|
+
calculateBytes() {
|
|
58
|
+
switch (this.unit) {
|
|
59
59
|
case SizeUnit.kB:
|
|
60
|
-
return SizeValue.parse(
|
|
60
|
+
return SizeValue.parse(this.value * Size.KB_MULTIPLIER);
|
|
61
61
|
case SizeUnit.MB:
|
|
62
|
-
return SizeValue.parse(
|
|
62
|
+
return SizeValue.parse(this.value * Size.MB_MULTIPLIER);
|
|
63
63
|
case SizeUnit.GB:
|
|
64
|
-
return SizeValue.parse(
|
|
64
|
+
return SizeValue.parse(this.value * Size.GB_MULTIPLIER);
|
|
65
65
|
default:
|
|
66
66
|
// SizeUnit.b
|
|
67
|
-
return
|
|
67
|
+
return this.value;
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
}
|
package/dist/timestamp.vo.js
CHANGED
package/package.json
CHANGED
package/src/iban.vo.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import type { TimeResult } from "./time.service";
|
|
1
2
|
import { Timestamp, TimestampType } from "./timestamp.vo";
|
|
2
3
|
import type { Falsy } from "./ts-utils";
|
|
3
4
|
|
|
4
|
-
type RateLimiterOptionsType =
|
|
5
|
+
type RateLimiterOptionsType = Pick<TimeResult, "ms">;
|
|
5
6
|
|
|
6
7
|
type RateLimiterResultSuccessType = { allowed: true };
|
|
7
8
|
|
package/src/size.vo.ts
CHANGED
|
@@ -11,9 +11,9 @@ export enum SizeUnit {
|
|
|
11
11
|
|
|
12
12
|
const SizeValue = z.number().positive().brand("SizeValue");
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
type SizeValueType = z.infer<typeof SizeValue>;
|
|
15
15
|
|
|
16
|
-
type SizeConfigType = { unit: SizeUnit; value:
|
|
16
|
+
type SizeConfigType = { unit: SizeUnit; value: number };
|
|
17
17
|
|
|
18
18
|
export class Size {
|
|
19
19
|
private readonly unit: SizeUnit;
|
|
@@ -31,7 +31,7 @@ export class Size {
|
|
|
31
31
|
constructor(config: SizeConfigType) {
|
|
32
32
|
this.unit = config.unit;
|
|
33
33
|
this.value = SizeValue.parse(config.value);
|
|
34
|
-
this.bytes = this.calculateBytes(
|
|
34
|
+
this.bytes = this.calculateBytes();
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
toString(): string {
|
|
@@ -78,17 +78,17 @@ export class Size {
|
|
|
78
78
|
|
|
79
79
|
static unit = SizeUnit;
|
|
80
80
|
|
|
81
|
-
private calculateBytes(
|
|
82
|
-
switch (
|
|
81
|
+
private calculateBytes(): SizeValueType {
|
|
82
|
+
switch (this.unit) {
|
|
83
83
|
case SizeUnit.kB:
|
|
84
|
-
return SizeValue.parse(
|
|
84
|
+
return SizeValue.parse(this.value * Size.KB_MULTIPLIER);
|
|
85
85
|
case SizeUnit.MB:
|
|
86
|
-
return SizeValue.parse(
|
|
86
|
+
return SizeValue.parse(this.value * Size.MB_MULTIPLIER);
|
|
87
87
|
case SizeUnit.GB:
|
|
88
|
-
return SizeValue.parse(
|
|
88
|
+
return SizeValue.parse(this.value * Size.GB_MULTIPLIER);
|
|
89
89
|
default:
|
|
90
90
|
// SizeUnit.b
|
|
91
|
-
return
|
|
91
|
+
return this.value;
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
}
|