@bgord/tools 1.4.5 → 1.4.7
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/package.json +3 -3
- package/dist/age-years.vo.d.ts +0 -11
- package/dist/age-years.vo.js +0 -6
- package/dist/age.vo.d.ts +0 -28
- package/dist/age.vo.js +0 -51
- package/dist/api-key.vo.d.ts +0 -7
- package/dist/api-key.vo.js +0 -7
- package/dist/basename.vo.d.ts +0 -12
- package/dist/basename.vo.js +0 -22
- package/dist/batch.d.ts +0 -2
- package/dist/batch.js +0 -3
- package/dist/date-calculator.service.d.ts +0 -10
- package/dist/date-calculator.service.js +0 -12
- package/dist/date-formatter.service.d.ts +0 -9
- package/dist/date-formatter.service.js +0 -15
- package/dist/date-range.vo.d.ts +0 -21
- package/dist/date-range.vo.js +0 -35
- package/dist/day-iso-id.vo.d.ts +0 -9
- package/dist/day-iso-id.vo.js +0 -12
- package/dist/day.vo.d.ts +0 -16
- package/dist/day.vo.js +0 -43
- package/dist/directory-path-absolute.vo.d.ts +0 -12
- package/dist/directory-path-absolute.vo.js +0 -20
- package/dist/directory-path-relative.vo.d.ts +0 -12
- package/dist/directory-path-relative.vo.js +0 -17
- package/dist/distance-value.vo.d.ts +0 -7
- package/dist/distance-value.vo.js +0 -5
- package/dist/distance.vo.d.ts +0 -23
- package/dist/distance.vo.js +0 -53
- package/dist/division-factor.vo.d.ts +0 -7
- package/dist/division-factor.vo.js +0 -5
- package/dist/dll.service.d.ts +0 -29
- package/dist/dll.service.js +0 -148
- package/dist/duration-ms.vo.d.ts +0 -6
- package/dist/duration-ms.vo.js +0 -5
- package/dist/duration.service.d.ts +0 -37
- package/dist/duration.service.js +0 -87
- package/dist/email-mask.service.d.ts +0 -4
- package/dist/email-mask.service.js +0 -12
- package/dist/email.vo.d.ts +0 -6
- package/dist/email.vo.js +0 -4
- package/dist/etags.vo.d.ts +0 -23
- package/dist/etags.vo.js +0 -37
- package/dist/extension.vo.d.ts +0 -9
- package/dist/extension.vo.js +0 -15
- package/dist/feature-flag-value.vo.d.ts +0 -10
- package/dist/feature-flag-value.vo.js +0 -8
- package/dist/feature-flag.vo.d.ts +0 -5
- package/dist/feature-flag.vo.js +0 -9
- package/dist/file-path-absolute-schema.vo.d.ts +0 -17
- package/dist/file-path-absolute-schema.vo.js +0 -20
- package/dist/file-path-relative-schema.vo.d.ts +0 -17
- package/dist/file-path-relative-schema.vo.js +0 -20
- package/dist/file-path.vo.d.ts +0 -31
- package/dist/file-path.vo.js +0 -81
- package/dist/filename-affix.vo.d.ts +0 -13
- package/dist/filename-affix.vo.js +0 -17
- package/dist/filename-from-string.vo.d.ts +0 -10
- package/dist/filename-from-string.vo.js +0 -17
- package/dist/filename.vo.d.ts +0 -24
- package/dist/filename.vo.js +0 -69
- package/dist/height-milimiters.vo.d.ts +0 -7
- package/dist/height-milimiters.vo.js +0 -8
- package/dist/height.vo.d.ts +0 -21
- package/dist/height.vo.js +0 -51
- package/dist/hour-value.vo.d.ts +0 -7
- package/dist/hour-value.vo.js +0 -5
- package/dist/hour.vo.d.ts +0 -20
- package/dist/hour.vo.js +0 -48
- package/dist/iban-mask.service.d.ts +0 -4
- package/dist/iban-mask.service.js +0 -12
- package/dist/iban-schema.vo.d.ts +0 -7
- package/dist/iban-schema.vo.js +0 -7
- package/dist/iban.vo.d.ts +0 -9
- package/dist/iban.vo.js +0 -23
- package/dist/image.vo.d.ts +0 -13
- package/dist/image.vo.js +0 -10
- package/dist/index.d.ts +0 -110
- package/dist/index.js +0 -110
- package/dist/int.vo.d.ts +0 -8
- package/dist/int.vo.js +0 -15
- package/dist/integer-non-negative.vo.d.ts +0 -7
- package/dist/integer-non-negative.vo.js +0 -8
- package/dist/integer-positive.vo.d.ts +0 -7
- package/dist/integer-positive.vo.js +0 -5
- package/dist/integer.vo.d.ts +0 -6
- package/dist/integer.vo.js +0 -4
- package/dist/language.vo.d.ts +0 -7
- package/dist/language.vo.js +0 -5
- package/dist/linear-regression.service.d.ts +0 -27
- package/dist/linear-regression.service.js +0 -58
- package/dist/mean.service.d.ts +0 -8
- package/dist/mean.service.js +0 -13
- package/dist/mime-registry-entry.vo.d.ts +0 -7
- package/dist/mime-registry-entry.vo.js +0 -8
- package/dist/mime-registry.service.d.ts +0 -16
- package/dist/mime-registry.service.js +0 -31
- package/dist/mime-value.vo.d.ts +0 -7
- package/dist/mime-value.vo.js +0 -7
- package/dist/mime.vo.d.ts +0 -12
- package/dist/mime.vo.js +0 -26
- package/dist/mimes.d.ts +0 -13
- package/dist/mimes.js +0 -19
- package/dist/min-max-scaler.service.d.ts +0 -46
- package/dist/min-max-scaler.service.js +0 -61
- package/dist/minute-value.vo.d.ts +0 -7
- package/dist/minute-value.vo.js +0 -5
- package/dist/minute.vo.d.ts +0 -20
- package/dist/minute.vo.js +0 -48
- package/dist/money-amount.vo.d.ts +0 -7
- package/dist/money-amount.vo.js +0 -5
- package/dist/money.vo.d.ts +0 -26
- package/dist/money.vo.js +0 -56
- package/dist/month-iso-id.vo.d.ts +0 -8
- package/dist/month-iso-id.vo.js +0 -14
- package/dist/month.vo.d.ts +0 -16
- package/dist/month.vo.js +0 -40
- package/dist/multiplication-factor.vo.d.ts +0 -7
- package/dist/multiplication-factor.vo.js +0 -8
- package/dist/noop.service.d.ts +0 -2
- package/dist/noop.service.js +0 -2
- package/dist/object-key.vo.d.ts +0 -11
- package/dist/object-key.vo.js +0 -19
- package/dist/outlier-detector.service.d.ts +0 -9
- package/dist/outlier-detector.service.js +0 -16
- package/dist/package-version-schema.vo.d.ts +0 -8
- package/dist/package-version-schema.vo.js +0 -10
- package/dist/package-version.vo.d.ts +0 -22
- package/dist/package-version.vo.js +0 -58
- package/dist/pagination-page.vo.d.ts +0 -6
- package/dist/pagination-page.vo.js +0 -3
- package/dist/pagination-skip.vo.d.ts +0 -7
- package/dist/pagination-skip.vo.js +0 -3
- package/dist/pagination-take.vo.d.ts +0 -7
- package/dist/pagination-take.vo.js +0 -3
- package/dist/pagination.service.d.ts +0 -53
- package/dist/pagination.service.js +0 -44
- package/dist/percentage.service.d.ts +0 -7
- package/dist/percentage.service.js +0 -9
- package/dist/population-standard-deviation.service.d.ts +0 -7
- package/dist/population-standard-deviation.service.js +0 -17
- package/dist/quarter-iso-id.vo.d.ts +0 -8
- package/dist/quarter-iso-id.vo.js +0 -7
- package/dist/quarter.vo.d.ts +0 -12
- package/dist/quarter.vo.js +0 -30
- package/dist/random.service.d.ts +0 -13
- package/dist/random.service.js +0 -13
- package/dist/rate-limiter.service.d.ts +0 -17
- package/dist/rate-limiter.service.js +0 -19
- package/dist/relative-date.vo.d.ts +0 -13
- package/dist/relative-date.vo.js +0 -14
- package/dist/reordering-item-position-value.vo.d.ts +0 -6
- package/dist/reordering-item-position-value.vo.js +0 -3
- package/dist/reordering.service.d.ts +0 -63
- package/dist/reordering.service.js +0 -135
- package/dist/repeat.d.ts +0 -1
- package/dist/repeat.js +0 -3
- package/dist/revision-value.vo.d.ts +0 -7
- package/dist/revision-value.vo.js +0 -3
- package/dist/revision.vo.d.ts +0 -18
- package/dist/revision.vo.js +0 -36
- package/dist/rounding-decimal.strategy.d.ts +0 -12
- package/dist/rounding-decimal.strategy.js +0 -14
- package/dist/rounding-down.strategy.d.ts +0 -4
- package/dist/rounding-down.strategy.js +0 -5
- package/dist/rounding-to-nearest.strategy.d.ts +0 -4
- package/dist/rounding-to-nearest.strategy.js +0 -5
- package/dist/rounding-up.strategy.d.ts +0 -4
- package/dist/rounding-up.strategy.js +0 -5
- package/dist/rounding.strategy.d.ts +0 -3
- package/dist/rounding.strategy.js +0 -1
- package/dist/size-bytes.vo.d.ts +0 -6
- package/dist/size-bytes.vo.js +0 -5
- package/dist/size.vo.d.ts +0 -41
- package/dist/size.vo.js +0 -91
- package/dist/slug.service.d.ts +0 -4
- package/dist/slug.service.js +0 -15
- package/dist/sms-body.vo.d.ts +0 -8
- package/dist/sms-body.vo.js +0 -9
- package/dist/sms-message.vo.d.ts +0 -13
- package/dist/sms-message.vo.js +0 -13
- package/dist/sum.service.d.ts +0 -4
- package/dist/sum.service.js +0 -16
- package/dist/telephone-number.vo.d.ts +0 -7
- package/dist/telephone-number.vo.js +0 -10
- package/dist/thousands-separator.service.d.ts +0 -4
- package/dist/thousands-separator.service.js +0 -9
- package/dist/time-zone-offset-value.vo.d.ts +0 -8
- package/dist/time-zone-offset-value.vo.js +0 -13
- package/dist/timestamp-value.vo.d.ts +0 -6
- package/dist/timestamp-value.vo.js +0 -5
- package/dist/timestamp.vo.d.ts +0 -21
- package/dist/timestamp.vo.js +0 -54
- package/dist/timezone.vo.d.ts +0 -9
- package/dist/timezone.vo.js +0 -20
- package/dist/ts-utils.d.ts +0 -3
- package/dist/ts-utils.js +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/dist/url-with-slash.vo.d.ts +0 -6
- package/dist/url-with-slash.vo.js +0 -5
- package/dist/url-without-slash.vo.d.ts +0 -6
- package/dist/url-without-slash.vo.js +0 -5
- package/dist/visually-unambiguous-characters-generator.service.d.ts +0 -4
- package/dist/visually-unambiguous-characters-generator.service.js +0 -32
- package/dist/week-iso-id.vo.d.ts +0 -8
- package/dist/week-iso-id.vo.js +0 -19
- package/dist/week.vo.d.ts +0 -16
- package/dist/week.vo.js +0 -45
- package/dist/weekday-iso-id.vo.d.ts +0 -7
- package/dist/weekday-iso-id.vo.js +0 -5
- package/dist/weekday.vo.d.ts +0 -28
- package/dist/weekday.vo.js +0 -60
- package/dist/weight-grams.vo.d.ts +0 -7
- package/dist/weight-grams.vo.js +0 -5
- package/dist/weight.vo.d.ts +0 -25
- package/dist/weight.vo.js +0 -65
- package/dist/year-iso-id.vo.d.ts +0 -7
- package/dist/year-iso-id.vo.js +0 -7
- package/dist/year.vo.d.ts +0 -18
- package/dist/year.vo.js +0 -50
- package/dist/z-score.service.d.ts +0 -11
- package/dist/z-score.service.js +0 -19
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import * as v from "valibot";
|
|
2
|
-
export declare const TimestampValueError: {
|
|
3
|
-
Invalid: string;
|
|
4
|
-
};
|
|
5
|
-
export declare const TimestampValue: v.SchemaWithPipe<readonly [v.NumberSchema<string>, v.IntegerAction<number, string>, v.MinValueAction<number, 0, string>, v.BrandAction<number, "TimestampValue">]>;
|
|
6
|
-
export type TimestampValueType = v.InferOutput<typeof TimestampValue>;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import * as v from "valibot";
|
|
2
|
-
export const TimestampValueError = { Invalid: "timestamp.invalid" };
|
|
3
|
-
export const TimestampValue = v.pipe(v.number(TimestampValueError.Invalid), v.integer(TimestampValueError.Invalid), v.minValue(0, TimestampValueError.Invalid),
|
|
4
|
-
// Stryker disable next-line StringLiteral
|
|
5
|
-
v.brand("TimestampValue"));
|
package/dist/timestamp.vo.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { Duration } from "./duration.service";
|
|
2
|
-
import { type TimestampValueType } from "./timestamp-value.vo";
|
|
3
|
-
export declare class Timestamp {
|
|
4
|
-
private readonly value;
|
|
5
|
-
constructor(value: TimestampValueType);
|
|
6
|
-
static fromValue(value: TimestampValueType): Timestamp;
|
|
7
|
-
static fromNumber(value: number): Timestamp;
|
|
8
|
-
static fromDate(value: Date): Timestamp;
|
|
9
|
-
static fromDateLike(value: string): Timestamp;
|
|
10
|
-
add(duration: Duration): Timestamp;
|
|
11
|
-
subtract(duration: Duration): Timestamp;
|
|
12
|
-
difference(another: Timestamp): Duration;
|
|
13
|
-
isBefore(another: Timestamp): boolean;
|
|
14
|
-
isBeforeOrEqual(another: Timestamp): boolean;
|
|
15
|
-
isAfter(another: Timestamp): boolean;
|
|
16
|
-
isAfterOrEqual(another: Timestamp): boolean;
|
|
17
|
-
equals(another: Timestamp): boolean;
|
|
18
|
-
get ms(): TimestampValueType;
|
|
19
|
-
toJSON(): TimestampValueType;
|
|
20
|
-
toString(): string;
|
|
21
|
-
}
|
package/dist/timestamp.vo.js
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import * as v from "valibot";
|
|
2
|
-
import { Duration } from "./duration.service";
|
|
3
|
-
import { TimestampValue } from "./timestamp-value.vo";
|
|
4
|
-
export class Timestamp {
|
|
5
|
-
value;
|
|
6
|
-
constructor(value) {
|
|
7
|
-
this.value = value;
|
|
8
|
-
}
|
|
9
|
-
static fromValue(value) {
|
|
10
|
-
return new Timestamp(value);
|
|
11
|
-
}
|
|
12
|
-
static fromNumber(value) {
|
|
13
|
-
return new Timestamp(v.parse(TimestampValue, value));
|
|
14
|
-
}
|
|
15
|
-
static fromDate(value) {
|
|
16
|
-
return Timestamp.fromNumber(value.getTime());
|
|
17
|
-
}
|
|
18
|
-
static fromDateLike(value) {
|
|
19
|
-
return Timestamp.fromNumber(new Date(value).getTime());
|
|
20
|
-
}
|
|
21
|
-
add(duration) {
|
|
22
|
-
return Timestamp.fromNumber(this.value + duration.ms);
|
|
23
|
-
}
|
|
24
|
-
subtract(duration) {
|
|
25
|
-
return Timestamp.fromNumber(this.value - duration.ms);
|
|
26
|
-
}
|
|
27
|
-
difference(another) {
|
|
28
|
-
return Duration.Ms(this.value - another.value);
|
|
29
|
-
}
|
|
30
|
-
isBefore(another) {
|
|
31
|
-
return this.value < another.value;
|
|
32
|
-
}
|
|
33
|
-
isBeforeOrEqual(another) {
|
|
34
|
-
return this.value <= another.value;
|
|
35
|
-
}
|
|
36
|
-
isAfter(another) {
|
|
37
|
-
return this.value > another.value;
|
|
38
|
-
}
|
|
39
|
-
isAfterOrEqual(another) {
|
|
40
|
-
return this.value >= another.value;
|
|
41
|
-
}
|
|
42
|
-
equals(another) {
|
|
43
|
-
return this.value === another.value;
|
|
44
|
-
}
|
|
45
|
-
get ms() {
|
|
46
|
-
return this.value;
|
|
47
|
-
}
|
|
48
|
-
toJSON() {
|
|
49
|
-
return this.value;
|
|
50
|
-
}
|
|
51
|
-
toString() {
|
|
52
|
-
return this.value.toString();
|
|
53
|
-
}
|
|
54
|
-
}
|
package/dist/timezone.vo.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import * as v from "valibot";
|
|
2
|
-
export declare const TimezoneError: {
|
|
3
|
-
Type: string;
|
|
4
|
-
Empty: string;
|
|
5
|
-
TooLong: string;
|
|
6
|
-
Invalid: string;
|
|
7
|
-
};
|
|
8
|
-
export declare const Timezone: v.SchemaWithPipe<readonly [v.StringSchema<string>, v.MinLengthAction<string, 1, string>, v.MaxLengthAction<string, 128, string>, v.CheckAction<string, string>, v.BrandAction<string, "Timezone">]>;
|
|
9
|
-
export type TimezoneType = v.InferOutput<typeof Timezone>;
|
package/dist/timezone.vo.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import * as v from "valibot";
|
|
2
|
-
export const TimezoneError = {
|
|
3
|
-
Type: "timezone.type",
|
|
4
|
-
Empty: "timezone.empty",
|
|
5
|
-
TooLong: "timezone.too.long",
|
|
6
|
-
Invalid: "timezone.invalid",
|
|
7
|
-
};
|
|
8
|
-
export const Timezone = v.pipe(v.string(TimezoneError.Type), v.minLength(1, TimezoneError.Empty), v.maxLength(128, TimezoneError.TooLong), v.check((value) => {
|
|
9
|
-
// Stryker disable all
|
|
10
|
-
try {
|
|
11
|
-
new Intl.DateTimeFormat("en-US", { timeZone: value }).format(Date.now());
|
|
12
|
-
return true;
|
|
13
|
-
}
|
|
14
|
-
catch {
|
|
15
|
-
return false;
|
|
16
|
-
}
|
|
17
|
-
// Stryker restore all
|
|
18
|
-
}, TimezoneError.Invalid),
|
|
19
|
-
// Stryker disable next-line StringLiteral
|
|
20
|
-
v.brand("Timezone"));
|
package/dist/ts-utils.d.ts
DELETED
package/dist/ts-utils.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
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/sms-body.vo.ts","../src/sms-message.vo.ts","../src/sum.service.ts","../src/telephone-number.vo.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,6 +0,0 @@
|
|
|
1
|
-
import * as v from "valibot";
|
|
2
|
-
export declare const UrlWithSlashError: {
|
|
3
|
-
Invalid: string;
|
|
4
|
-
};
|
|
5
|
-
export declare const UrlWithSlash: v.SchemaWithPipe<readonly [v.StringSchema<string>, v.UrlAction<string, string>, v.EndsWithAction<string, "/", string>, v.BrandAction<string, "UrlWithSlash">]>;
|
|
6
|
-
export type UrlWithSlashType = v.InferOutput<typeof UrlWithSlash>;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import * as v from "valibot";
|
|
2
|
-
export const UrlWithSlashError = { Invalid: "url.with.slash.invalid" };
|
|
3
|
-
export const UrlWithSlash = v.pipe(v.string(UrlWithSlashError.Invalid), v.url(UrlWithSlashError.Invalid), v.endsWith("/", UrlWithSlashError.Invalid),
|
|
4
|
-
// Stryker disable next-line StringLiteral
|
|
5
|
-
v.brand("UrlWithSlash"));
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import * as v from "valibot";
|
|
2
|
-
export declare const UrlWithoutSlashError: {
|
|
3
|
-
Invalid: string;
|
|
4
|
-
};
|
|
5
|
-
export declare const UrlWithoutSlash: v.SchemaWithPipe<readonly [v.StringSchema<string>, v.UrlAction<string, string>, v.CheckAction<string, string>, v.BrandAction<string, "UrlWithoutSlash">]>;
|
|
6
|
-
export type UrlWithoutSlashType = v.InferOutput<typeof UrlWithoutSlash>;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import * as v from "valibot";
|
|
2
|
-
export const UrlWithoutSlashError = { Invalid: "url.without.slash.invalid" };
|
|
3
|
-
export const UrlWithoutSlash = v.pipe(v.string(UrlWithoutSlashError.Invalid), v.url(UrlWithoutSlashError.Invalid), v.check((value) => !value.endsWith("/"), UrlWithoutSlashError.Invalid),
|
|
4
|
-
// Stryker disable next-line StringLiteral
|
|
5
|
-
v.brand("UrlWithoutSlash"));
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { Random } from "./random.service";
|
|
2
|
-
export class VisuallyUnambiguousCharactersGenerator {
|
|
3
|
-
static chars = [
|
|
4
|
-
"a",
|
|
5
|
-
"b",
|
|
6
|
-
"c",
|
|
7
|
-
"d",
|
|
8
|
-
"e",
|
|
9
|
-
"f",
|
|
10
|
-
"h",
|
|
11
|
-
"i",
|
|
12
|
-
"j",
|
|
13
|
-
"k",
|
|
14
|
-
"m",
|
|
15
|
-
"n",
|
|
16
|
-
"o",
|
|
17
|
-
"p",
|
|
18
|
-
"r",
|
|
19
|
-
"s",
|
|
20
|
-
"t",
|
|
21
|
-
"w",
|
|
22
|
-
"x",
|
|
23
|
-
"y",
|
|
24
|
-
"3",
|
|
25
|
-
"4",
|
|
26
|
-
];
|
|
27
|
-
static generate(length = 1) {
|
|
28
|
-
return Array.from({ length })
|
|
29
|
-
.map(() => VisuallyUnambiguousCharactersGenerator.chars[Random.generate({ min: 0, max: VisuallyUnambiguousCharactersGenerator.chars.length - 1 })])
|
|
30
|
-
.join("");
|
|
31
|
-
}
|
|
32
|
-
}
|
package/dist/week-iso-id.vo.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import * as v from "valibot";
|
|
2
|
-
export declare const WeekIsoIdError: {
|
|
3
|
-
Type: string;
|
|
4
|
-
BadChars: string;
|
|
5
|
-
Invalid: string;
|
|
6
|
-
};
|
|
7
|
-
export declare const WeekIsoId: v.SchemaWithPipe<readonly [v.StringSchema<string>, v.RegexAction<string, string>, v.CheckAction<string, string>, v.BrandAction<string, "WeekIsoId">]>;
|
|
8
|
-
export type WeekIsoIdType = v.InferOutput<typeof WeekIsoId>;
|
package/dist/week-iso-id.vo.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { getISOWeeksInYear } from "date-fns";
|
|
2
|
-
import * as v from "valibot";
|
|
3
|
-
export const WeekIsoIdError = {
|
|
4
|
-
Type: "week.iso.id.type",
|
|
5
|
-
BadChars: "week.iso.id.bad.chars",
|
|
6
|
-
Invalid: "week.iso.id.invalid",
|
|
7
|
-
};
|
|
8
|
-
// Four digits, hypen, W, followed by two digits
|
|
9
|
-
const WEEK_ISO_ID_CHARS_WHITELIST = /^[0-9]{4}-W[0-9]{2}$/;
|
|
10
|
-
export const WeekIsoId = v.pipe(v.string(WeekIsoIdError.Type), v.regex(WEEK_ISO_ID_CHARS_WHITELIST, WeekIsoIdError.BadChars), v.check((value) => {
|
|
11
|
-
const [year, week] = value.split("-W").map(Number);
|
|
12
|
-
// ISO-8601 rule: Jan 4 is always in week 01 of the ISO week-year.
|
|
13
|
-
const weeksInYear = getISOWeeksInYear(Date.UTC(year, 0, 4));
|
|
14
|
-
if (week < 1)
|
|
15
|
-
return false;
|
|
16
|
-
return week <= weeksInYear;
|
|
17
|
-
}, WeekIsoIdError.Invalid),
|
|
18
|
-
// Stryker disable next-line StringLiteral
|
|
19
|
-
v.brand("WeekIsoId"));
|
package/dist/week.vo.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { DateRange } from "./date-range.vo";
|
|
2
|
-
import type { IntegerType } from "./integer.vo";
|
|
3
|
-
import { Timestamp } from "./timestamp.vo";
|
|
4
|
-
import type { TimestampValueType } from "./timestamp-value.vo";
|
|
5
|
-
import { type WeekIsoIdType } from "./week-iso-id.vo";
|
|
6
|
-
export declare class Week extends DateRange {
|
|
7
|
-
static fromTimestamp(timestamp: Timestamp): Week;
|
|
8
|
-
static fromTimestampValue(timestamp: TimestampValueType): Week;
|
|
9
|
-
static fromNow(now: Timestamp): Week;
|
|
10
|
-
static fromIsoId(isoId: WeekIsoIdType): Week;
|
|
11
|
-
toIsoId(): WeekIsoIdType;
|
|
12
|
-
previous(): Week;
|
|
13
|
-
next(): Week;
|
|
14
|
-
shift(count: IntegerType): Week;
|
|
15
|
-
toString(): string;
|
|
16
|
-
}
|
package/dist/week.vo.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { addWeeks, endOfISOWeek, getISOWeek, getISOWeekYear, startOfISOWeek } from "date-fns";
|
|
2
|
-
import * as v from "valibot";
|
|
3
|
-
import { DateRange } from "./date-range.vo";
|
|
4
|
-
import { Duration } from "./duration.service";
|
|
5
|
-
import { Int } from "./int.vo";
|
|
6
|
-
import { Timestamp } from "./timestamp.vo";
|
|
7
|
-
import { WeekIsoId } from "./week-iso-id.vo";
|
|
8
|
-
export class Week extends DateRange {
|
|
9
|
-
static fromTimestamp(timestamp) {
|
|
10
|
-
const start = Timestamp.fromNumber(startOfISOWeek(timestamp.ms).getTime());
|
|
11
|
-
const end = Timestamp.fromNumber(endOfISOWeek(timestamp.ms).getTime());
|
|
12
|
-
return new Week(start, end);
|
|
13
|
-
}
|
|
14
|
-
static fromTimestampValue(timestamp) {
|
|
15
|
-
return Week.fromTimestamp(Timestamp.fromValue(timestamp));
|
|
16
|
-
}
|
|
17
|
-
static fromNow(now) {
|
|
18
|
-
return Week.fromTimestamp(now);
|
|
19
|
-
}
|
|
20
|
-
static fromIsoId(isoId) {
|
|
21
|
-
const [year, week] = v.parse(WeekIsoId, isoId).split("-W").map(Number);
|
|
22
|
-
// ISO-8601 rule: Jan 4 is always in week 01 of the ISO week-year.
|
|
23
|
-
const januaryFourth = Timestamp.fromNumber(Date.UTC(year, 0, 4));
|
|
24
|
-
const firstWeekStart = Timestamp.fromNumber(startOfISOWeek(januaryFourth.ms).getTime());
|
|
25
|
-
return Week.fromTimestamp(firstWeekStart.add(Duration.Weeks(week - 1)));
|
|
26
|
-
}
|
|
27
|
-
toIsoId() {
|
|
28
|
-
const year = getISOWeekYear(this.getStart().ms);
|
|
29
|
-
const week = getISOWeek(this.getStart().ms);
|
|
30
|
-
return v.parse(WeekIsoId, `${year}-W${String(week).padStart(2, "0")}`);
|
|
31
|
-
}
|
|
32
|
-
previous() {
|
|
33
|
-
return this.shift(Int.of(-1));
|
|
34
|
-
}
|
|
35
|
-
next() {
|
|
36
|
-
return this.shift(Int.of(1));
|
|
37
|
-
}
|
|
38
|
-
shift(count) {
|
|
39
|
-
const shifted = addWeeks(this.getStart().ms, count).getTime();
|
|
40
|
-
return Week.fromTimestamp(Timestamp.fromNumber(shifted));
|
|
41
|
-
}
|
|
42
|
-
toString() {
|
|
43
|
-
return this.toIsoId();
|
|
44
|
-
}
|
|
45
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import * as v from "valibot";
|
|
2
|
-
export declare const WeekdayIsoIdError: {
|
|
3
|
-
Type: string;
|
|
4
|
-
Invalid: string;
|
|
5
|
-
};
|
|
6
|
-
export declare const WeekdayIsoId: v.SchemaWithPipe<readonly [v.NumberSchema<string>, v.IntegerAction<number, string>, v.MinValueAction<number, 1, string>, v.MaxValueAction<number, 7, string>, v.BrandAction<number, "WeekdayIsoId">]>;
|
|
7
|
-
export type WeekdayIsoIdType = v.InferOutput<typeof WeekdayIsoId>;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import * as v from "valibot";
|
|
2
|
-
export const WeekdayIsoIdError = { Type: "weekday.iso.id.type", Invalid: "weekday.iso.id.invalid" };
|
|
3
|
-
export const WeekdayIsoId = v.pipe(v.number(WeekdayIsoIdError.Type), v.integer(WeekdayIsoIdError.Type), v.minValue(1, WeekdayIsoIdError.Invalid), v.maxValue(7, WeekdayIsoIdError.Invalid),
|
|
4
|
-
// Stryker disable next-line StringLiteral
|
|
5
|
-
v.brand("WeekdayIsoId"));
|
package/dist/weekday.vo.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { Timestamp } from "./timestamp.vo";
|
|
2
|
-
import type { TimestampValueType } from "./timestamp-value.vo";
|
|
3
|
-
import { type WeekdayIsoIdType } from "./weekday-iso-id.vo";
|
|
4
|
-
export declare class Weekday {
|
|
5
|
-
private readonly value;
|
|
6
|
-
static readonly MONDAY: Weekday;
|
|
7
|
-
static readonly TUESDAY: Weekday;
|
|
8
|
-
static readonly WEDNESDAY: Weekday;
|
|
9
|
-
static readonly THURSDAY: Weekday;
|
|
10
|
-
static readonly FRIDAY: Weekday;
|
|
11
|
-
static readonly SATURDAY: Weekday;
|
|
12
|
-
static readonly SUNDAY: Weekday;
|
|
13
|
-
private constructor();
|
|
14
|
-
static fromTimestamp(timestamp: Timestamp): Weekday;
|
|
15
|
-
static fromTimestampValue(timestamp: TimestampValueType): Weekday;
|
|
16
|
-
static fromIsoId(iso: WeekdayIsoIdType): Weekday;
|
|
17
|
-
get(): WeekdayIsoIdType;
|
|
18
|
-
equals(another: Weekday): boolean;
|
|
19
|
-
isMonday(): boolean;
|
|
20
|
-
isTuesday(): boolean;
|
|
21
|
-
isWednesday(): boolean;
|
|
22
|
-
isThursday(): boolean;
|
|
23
|
-
isFriday(): boolean;
|
|
24
|
-
isSaturday(): boolean;
|
|
25
|
-
isSunday(): boolean;
|
|
26
|
-
toJSON(): number;
|
|
27
|
-
toString(): string;
|
|
28
|
-
}
|
package/dist/weekday.vo.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import * as v from "valibot";
|
|
2
|
-
import { Timestamp } from "./timestamp.vo";
|
|
3
|
-
import { WeekdayIsoId } from "./weekday-iso-id.vo";
|
|
4
|
-
export class Weekday {
|
|
5
|
-
value;
|
|
6
|
-
static MONDAY = Weekday.fromIsoId(v.parse(WeekdayIsoId, 1));
|
|
7
|
-
static TUESDAY = Weekday.fromIsoId(v.parse(WeekdayIsoId, 2));
|
|
8
|
-
static WEDNESDAY = Weekday.fromIsoId(v.parse(WeekdayIsoId, 3));
|
|
9
|
-
static THURSDAY = Weekday.fromIsoId(v.parse(WeekdayIsoId, 4));
|
|
10
|
-
static FRIDAY = Weekday.fromIsoId(v.parse(WeekdayIsoId, 5));
|
|
11
|
-
static SATURDAY = Weekday.fromIsoId(v.parse(WeekdayIsoId, 6));
|
|
12
|
-
static SUNDAY = Weekday.fromIsoId(v.parse(WeekdayIsoId, 7));
|
|
13
|
-
constructor(value) {
|
|
14
|
-
this.value = value;
|
|
15
|
-
}
|
|
16
|
-
static fromTimestamp(timestamp) {
|
|
17
|
-
// UTC returns numbers from 0-6, starting from Sunday
|
|
18
|
-
const utc = new Date(timestamp.ms).getUTCDay();
|
|
19
|
-
return new Weekday(v.parse(WeekdayIsoId, utc === 0 ? 7 : utc));
|
|
20
|
-
}
|
|
21
|
-
static fromTimestampValue(timestamp) {
|
|
22
|
-
return Weekday.fromTimestamp(Timestamp.fromValue(timestamp));
|
|
23
|
-
}
|
|
24
|
-
static fromIsoId(iso) {
|
|
25
|
-
return new Weekday(iso);
|
|
26
|
-
}
|
|
27
|
-
get() {
|
|
28
|
-
return this.value;
|
|
29
|
-
}
|
|
30
|
-
equals(another) {
|
|
31
|
-
return this.value === another.value;
|
|
32
|
-
}
|
|
33
|
-
isMonday() {
|
|
34
|
-
return this.equals(Weekday.MONDAY);
|
|
35
|
-
}
|
|
36
|
-
isTuesday() {
|
|
37
|
-
return this.equals(Weekday.TUESDAY);
|
|
38
|
-
}
|
|
39
|
-
isWednesday() {
|
|
40
|
-
return this.equals(Weekday.WEDNESDAY);
|
|
41
|
-
}
|
|
42
|
-
isThursday() {
|
|
43
|
-
return this.equals(Weekday.THURSDAY);
|
|
44
|
-
}
|
|
45
|
-
isFriday() {
|
|
46
|
-
return this.equals(Weekday.FRIDAY);
|
|
47
|
-
}
|
|
48
|
-
isSaturday() {
|
|
49
|
-
return this.equals(Weekday.SATURDAY);
|
|
50
|
-
}
|
|
51
|
-
isSunday() {
|
|
52
|
-
return this.equals(Weekday.SUNDAY);
|
|
53
|
-
}
|
|
54
|
-
toJSON() {
|
|
55
|
-
return this.value;
|
|
56
|
-
}
|
|
57
|
-
toString() {
|
|
58
|
-
return this.value.toString();
|
|
59
|
-
}
|
|
60
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import * as v from "valibot";
|
|
2
|
-
export declare const WeightGramsError: {
|
|
3
|
-
Type: string;
|
|
4
|
-
Invalid: string;
|
|
5
|
-
};
|
|
6
|
-
export declare const WeightGrams: v.SchemaWithPipe<readonly [v.NumberSchema<string>, v.IntegerAction<number, string>, v.MinValueAction<number, 0, string>, v.BrandAction<number, "WeightGrams">]>;
|
|
7
|
-
export type WeightGramsType = v.InferOutput<typeof WeightGrams>;
|
package/dist/weight-grams.vo.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import * as v from "valibot";
|
|
2
|
-
export const WeightGramsError = { Type: "weight.grams.type", Invalid: "weight.grams.invalid" };
|
|
3
|
-
export const WeightGrams = v.pipe(v.number(WeightGramsError.Type), v.integer(WeightGramsError.Type), v.minValue(0, WeightGramsError.Invalid),
|
|
4
|
-
// Stryker disable next-line StringLiteral
|
|
5
|
-
v.brand("WeightGrams"));
|
package/dist/weight.vo.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type { DivisionFactorType } from "./division-factor.vo";
|
|
2
|
-
import type { MultiplicationFactorType } from "./multiplication-factor.vo";
|
|
3
|
-
import type { RoundingStrategy } from "./rounding.strategy";
|
|
4
|
-
export declare class Weight {
|
|
5
|
-
private readonly grams;
|
|
6
|
-
private readonly rounding;
|
|
7
|
-
private static readonly GRAMS_PER_KILOGRAM;
|
|
8
|
-
private constructor();
|
|
9
|
-
static fromKilograms(kilograms: number, rounding?: RoundingStrategy): Weight;
|
|
10
|
-
static fromGrams(grams: number, rounding?: RoundingStrategy): Weight;
|
|
11
|
-
static zero(): Weight;
|
|
12
|
-
get(): number;
|
|
13
|
-
toKilograms(): number;
|
|
14
|
-
format(): string;
|
|
15
|
-
add(other: Weight): Weight;
|
|
16
|
-
subtract(other: Weight): Weight;
|
|
17
|
-
multiply(factor: MultiplicationFactorType): Weight;
|
|
18
|
-
divide(divisor: DivisionFactorType): Weight;
|
|
19
|
-
equals(other: Weight): boolean;
|
|
20
|
-
greaterThan(other: Weight): boolean;
|
|
21
|
-
lessThan(other: Weight): boolean;
|
|
22
|
-
isZero(): boolean;
|
|
23
|
-
toString(): string;
|
|
24
|
-
toJSON(): number;
|
|
25
|
-
}
|
package/dist/weight.vo.js
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import * as v from "valibot";
|
|
2
|
-
import { RoundingToNearestStrategy } from "./rounding-to-nearest.strategy";
|
|
3
|
-
import { WeightGrams } from "./weight-grams.vo";
|
|
4
|
-
export class Weight {
|
|
5
|
-
grams;
|
|
6
|
-
rounding;
|
|
7
|
-
static GRAMS_PER_KILOGRAM = 1_000;
|
|
8
|
-
constructor(grams, rounding = new RoundingToNearestStrategy()) {
|
|
9
|
-
this.grams = grams;
|
|
10
|
-
this.rounding = rounding;
|
|
11
|
-
}
|
|
12
|
-
static fromKilograms(kilograms, rounding = new RoundingToNearestStrategy()) {
|
|
13
|
-
const grams = rounding.round(kilograms * Weight.GRAMS_PER_KILOGRAM);
|
|
14
|
-
return new Weight(v.parse(WeightGrams, grams), rounding);
|
|
15
|
-
}
|
|
16
|
-
static fromGrams(grams, rounding = new RoundingToNearestStrategy()) {
|
|
17
|
-
return new Weight(v.parse(WeightGrams, grams), rounding);
|
|
18
|
-
}
|
|
19
|
-
static zero() {
|
|
20
|
-
return new Weight(v.parse(WeightGrams, 0));
|
|
21
|
-
}
|
|
22
|
-
get() {
|
|
23
|
-
return this.grams;
|
|
24
|
-
}
|
|
25
|
-
toKilograms() {
|
|
26
|
-
const kilograms = this.grams / Weight.GRAMS_PER_KILOGRAM;
|
|
27
|
-
return this.rounding.round(kilograms);
|
|
28
|
-
}
|
|
29
|
-
format() {
|
|
30
|
-
return `${this.grams} g`;
|
|
31
|
-
}
|
|
32
|
-
add(other) {
|
|
33
|
-
return new Weight(v.parse(WeightGrams, this.grams + other.grams));
|
|
34
|
-
}
|
|
35
|
-
subtract(other) {
|
|
36
|
-
const result = this.grams - other.grams;
|
|
37
|
-
return new Weight(v.parse(WeightGrams, Math.max(0, result)), this.rounding);
|
|
38
|
-
}
|
|
39
|
-
multiply(factor) {
|
|
40
|
-
const grams = this.rounding.round(this.grams * factor);
|
|
41
|
-
return new Weight(v.parse(WeightGrams, grams));
|
|
42
|
-
}
|
|
43
|
-
divide(divisor) {
|
|
44
|
-
const grams = this.rounding.round(this.grams / divisor);
|
|
45
|
-
return new Weight(v.parse(WeightGrams, grams));
|
|
46
|
-
}
|
|
47
|
-
equals(other) {
|
|
48
|
-
return this.grams === other.grams;
|
|
49
|
-
}
|
|
50
|
-
greaterThan(other) {
|
|
51
|
-
return this.grams > other.grams;
|
|
52
|
-
}
|
|
53
|
-
lessThan(other) {
|
|
54
|
-
return this.grams < other.grams;
|
|
55
|
-
}
|
|
56
|
-
isZero() {
|
|
57
|
-
return this.grams === 0;
|
|
58
|
-
}
|
|
59
|
-
toString() {
|
|
60
|
-
return this.format();
|
|
61
|
-
}
|
|
62
|
-
toJSON() {
|
|
63
|
-
return this.grams;
|
|
64
|
-
}
|
|
65
|
-
}
|
package/dist/year-iso-id.vo.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import * as v from "valibot";
|
|
2
|
-
export declare const YearIsoIdError: {
|
|
3
|
-
Type: string;
|
|
4
|
-
BadChars: string;
|
|
5
|
-
};
|
|
6
|
-
export declare const YearIsoId: v.SchemaWithPipe<readonly [v.StringSchema<string>, v.RegexAction<string, string>, v.BrandAction<string, "YearIsoId">]>;
|
|
7
|
-
export type YearIsoIdType = v.InferOutput<typeof YearIsoId>;
|
package/dist/year-iso-id.vo.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import * as v from "valibot";
|
|
2
|
-
export const YearIsoIdError = { Type: "year.iso.id.type", BadChars: "year.iso.id.bad.chars" };
|
|
3
|
-
// Four digits
|
|
4
|
-
const YEAR_ISO_ID_CHARS_WHITELIST = /^[0-9]{4}$/;
|
|
5
|
-
export const YearIsoId = v.pipe(v.string(YearIsoIdError.Type), v.regex(YEAR_ISO_ID_CHARS_WHITELIST, YearIsoIdError.BadChars),
|
|
6
|
-
// Stryker disable next-line StringLiteral
|
|
7
|
-
v.brand("YearIsoId"));
|
package/dist/year.vo.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { DateRange } from "./date-range.vo";
|
|
2
|
-
import type { IntegerType } from "./integer.vo";
|
|
3
|
-
import { Timestamp } from "./timestamp.vo";
|
|
4
|
-
import type { TimestampValueType } from "./timestamp-value.vo";
|
|
5
|
-
import { type YearIsoIdType } from "./year-iso-id.vo";
|
|
6
|
-
export declare class Year extends DateRange {
|
|
7
|
-
static fromTimestamp(timestamp: Timestamp): Year;
|
|
8
|
-
static fromTimestampValue(timestamp: TimestampValueType): Year;
|
|
9
|
-
static fromNow(now: Timestamp): Year;
|
|
10
|
-
static fromNumber(candidate: number): Year;
|
|
11
|
-
static fromIsoId(isoId: YearIsoIdType): Year;
|
|
12
|
-
toIsoId(): YearIsoIdType;
|
|
13
|
-
isLeapYear(): boolean;
|
|
14
|
-
previous(): Year;
|
|
15
|
-
next(): Year;
|
|
16
|
-
shift(count: IntegerType): Year;
|
|
17
|
-
toString(): string;
|
|
18
|
-
}
|
package/dist/year.vo.js
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { endOfYear, getYear, startOfYear } from "date-fns";
|
|
2
|
-
import * as v from "valibot";
|
|
3
|
-
import { DateRange } from "./date-range.vo";
|
|
4
|
-
import { Int } from "./int.vo";
|
|
5
|
-
import { Timestamp } from "./timestamp.vo";
|
|
6
|
-
import { YearIsoId } from "./year-iso-id.vo";
|
|
7
|
-
export class Year extends DateRange {
|
|
8
|
-
static fromTimestamp(timestamp) {
|
|
9
|
-
const start = Timestamp.fromNumber(startOfYear(timestamp.ms).getTime());
|
|
10
|
-
const end = Timestamp.fromNumber(endOfYear(timestamp.ms).getTime());
|
|
11
|
-
return new Year(start, end);
|
|
12
|
-
}
|
|
13
|
-
static fromTimestampValue(timestamp) {
|
|
14
|
-
return Year.fromTimestamp(Timestamp.fromValue(timestamp));
|
|
15
|
-
}
|
|
16
|
-
static fromNow(now) {
|
|
17
|
-
return Year.fromTimestamp(now);
|
|
18
|
-
}
|
|
19
|
-
static fromNumber(candidate) {
|
|
20
|
-
return Year.fromIsoId(v.parse(YearIsoId, String(candidate)));
|
|
21
|
-
}
|
|
22
|
-
static fromIsoId(isoId) {
|
|
23
|
-
const year = Number(isoId);
|
|
24
|
-
return new Year(Timestamp.fromNumber(Date.UTC(year, 0, 1)), Timestamp.fromNumber(Date.UTC(year + 1, 0, 1) - 1));
|
|
25
|
-
}
|
|
26
|
-
toIsoId() {
|
|
27
|
-
return v.parse(YearIsoId, String(getYear(this.getStart().ms)));
|
|
28
|
-
}
|
|
29
|
-
isLeapYear() {
|
|
30
|
-
const year = getYear(this.getStart().ms);
|
|
31
|
-
if (year % 400 === 0)
|
|
32
|
-
return true;
|
|
33
|
-
if (year % 100 === 0)
|
|
34
|
-
return false;
|
|
35
|
-
return year % 4 === 0;
|
|
36
|
-
}
|
|
37
|
-
previous() {
|
|
38
|
-
return this.shift(Int.of(-1));
|
|
39
|
-
}
|
|
40
|
-
next() {
|
|
41
|
-
return this.shift(Int.of(1));
|
|
42
|
-
}
|
|
43
|
-
shift(count) {
|
|
44
|
-
const year = getYear(this.getStart().ms) + count;
|
|
45
|
-
return Year.fromNumber(year);
|
|
46
|
-
}
|
|
47
|
-
toString() {
|
|
48
|
-
return this.toIsoId();
|
|
49
|
-
}
|
|
50
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { RoundingStrategy } from "./rounding.strategy";
|
|
2
|
-
export declare const ZScoreError: {
|
|
3
|
-
NotEnoughValues: string;
|
|
4
|
-
};
|
|
5
|
-
export declare class ZScore {
|
|
6
|
-
private readonly rounding;
|
|
7
|
-
private readonly mean;
|
|
8
|
-
private readonly standardDeviation;
|
|
9
|
-
constructor(values: ReadonlyArray<number>, rounding?: RoundingStrategy);
|
|
10
|
-
calculate(value: number): number;
|
|
11
|
-
}
|
package/dist/z-score.service.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { Mean } from "./mean.service";
|
|
2
|
-
import { PopulationStandardDeviation } from "./population-standard-deviation.service";
|
|
3
|
-
import { RoundingDecimalStrategy } from "./rounding-decimal.strategy";
|
|
4
|
-
export const ZScoreError = { NotEnoughValues: "z.score.not.enough.values" };
|
|
5
|
-
export class ZScore {
|
|
6
|
-
rounding;
|
|
7
|
-
mean;
|
|
8
|
-
standardDeviation;
|
|
9
|
-
constructor(values, rounding = new RoundingDecimalStrategy(2)) {
|
|
10
|
-
this.rounding = rounding;
|
|
11
|
-
if (values.length < 2)
|
|
12
|
-
throw new Error(ZScoreError.NotEnoughValues);
|
|
13
|
-
this.mean = Mean.calculate(values);
|
|
14
|
-
this.standardDeviation = PopulationStandardDeviation.calculate(values);
|
|
15
|
-
}
|
|
16
|
-
calculate(value) {
|
|
17
|
-
return this.rounding.round((value - this.mean) / this.standardDeviation);
|
|
18
|
-
}
|
|
19
|
-
}
|