@bgord/tools 0.5.0 → 0.7.0

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 (98) hide show
  1. package/dist/clock.vo.d.ts +25 -0
  2. package/dist/clock.vo.js +45 -0
  3. package/dist/dll.service.d.ts +29 -0
  4. package/dist/dll.service.js +148 -0
  5. package/dist/email-mask.service.d.ts +6 -0
  6. package/dist/email-mask.service.js +14 -0
  7. package/dist/etags.vo.d.ts +4 -4
  8. package/dist/etags.vo.js +1 -1
  9. package/dist/feature-flag.vo.d.ts +11 -0
  10. package/dist/feature-flag.vo.js +15 -0
  11. package/dist/filter.vo.d.ts +17 -0
  12. package/dist/filter.vo.js +21 -0
  13. package/dist/hour.vo.d.ts +24 -0
  14. package/dist/hour.vo.js +52 -0
  15. package/dist/image.vo.d.ts +5 -0
  16. package/dist/image.vo.js +3 -0
  17. package/dist/index.d.ts +27 -0
  18. package/dist/index.js +27 -0
  19. package/dist/leap-year-checker.service.d.ts +4 -0
  20. package/dist/leap-year-checker.service.js +9 -0
  21. package/dist/mean.service.d.ts +4 -0
  22. package/dist/mean.service.js +11 -0
  23. package/dist/mime-types.vo.d.ts +2 -0
  24. package/dist/mime-types.vo.js +7 -0
  25. package/dist/mime.vo.d.ts +1 -1
  26. package/dist/min-max-scaler.service.d.ts +36 -0
  27. package/dist/min-max-scaler.service.js +58 -0
  28. package/dist/minute.vo.d.ts +14 -0
  29. package/dist/minute.vo.js +34 -0
  30. package/dist/money.vo.d.ts +24 -0
  31. package/dist/money.vo.js +64 -0
  32. package/dist/outlier-detector.service.d.ts +6 -0
  33. package/dist/outlier-detector.service.js +13 -0
  34. package/dist/package-version.vo.d.ts +2 -2
  35. package/dist/package-version.vo.js +3 -3
  36. package/dist/pagination.service.d.ts +58 -0
  37. package/dist/pagination.service.js +56 -0
  38. package/dist/percentage.service.d.ts +4 -0
  39. package/dist/percentage.service.js +11 -0
  40. package/dist/population-standard-deviation.service.d.ts +4 -0
  41. package/dist/population-standard-deviation.service.js +16 -0
  42. package/dist/random.service.d.ts +8 -0
  43. package/dist/random.service.js +19 -0
  44. package/dist/reordering.service.d.ts +61 -0
  45. package/dist/reordering.service.js +121 -0
  46. package/dist/revision.vo.d.ts +20 -0
  47. package/dist/revision.vo.js +45 -0
  48. package/dist/simple-linear-regression.service.d.ts +18 -0
  49. package/dist/simple-linear-regression.service.js +50 -0
  50. package/dist/size.vo.d.ts +2 -2
  51. package/dist/size.vo.js +2 -2
  52. package/dist/stepper.service.d.ts +23 -0
  53. package/dist/stepper.service.js +34 -0
  54. package/dist/streak-calculator.service.d.ts +14 -0
  55. package/dist/streak-calculator.service.js +27 -0
  56. package/dist/sum.service.d.ts +3 -0
  57. package/dist/sum.service.js +5 -0
  58. package/dist/thousands-separator.service.d.ts +4 -0
  59. package/dist/thousands-separator.service.js +6 -0
  60. package/dist/visually-unambiguous-characters-generator.service.d.ts +4 -0
  61. package/dist/visually-unambiguous-characters-generator.service.js +35 -0
  62. package/dist/z-score.service.d.ts +8 -0
  63. package/dist/z-score.service.js +16 -0
  64. package/package.json +2 -2
  65. package/src/api-key.vo.ts +1 -0
  66. package/src/clock.vo.ts +67 -0
  67. package/src/dll.service.ts +185 -0
  68. package/src/email-mask.service.ts +22 -0
  69. package/src/etags.vo.ts +4 -4
  70. package/src/feature-flag.vo.ts +19 -0
  71. package/src/filter.vo.ts +38 -0
  72. package/src/hour.vo.ts +71 -0
  73. package/src/image.vo.ts +9 -0
  74. package/src/index.ts +27 -0
  75. package/src/leap-year-checker.service.ts +11 -0
  76. package/src/mean.service.ts +14 -0
  77. package/src/mime-types.vo.ts +9 -0
  78. package/src/mime.vo.ts +3 -1
  79. package/src/min-max-scaler.service.ts +94 -0
  80. package/src/minute.vo.ts +46 -0
  81. package/src/money.vo.ts +99 -0
  82. package/src/outlier-detector.service.ts +20 -0
  83. package/src/package-version.vo.ts +6 -4
  84. package/src/pagination.service.ts +111 -0
  85. package/src/percentage.service.ts +17 -0
  86. package/src/population-standard-deviation.service.ts +21 -0
  87. package/src/random.service.ts +29 -0
  88. package/src/rate-limiter.service.ts +1 -3
  89. package/src/reordering.service.ts +169 -0
  90. package/src/revision.vo.ts +61 -0
  91. package/src/simple-linear-regression.service.ts +74 -0
  92. package/src/size.vo.ts +3 -3
  93. package/src/stepper.service.ts +50 -0
  94. package/src/streak-calculator.service.ts +42 -0
  95. package/src/sum.service.ts +5 -0
  96. package/src/thousands-separator.service.ts +7 -0
  97. package/src/visually-unambiguous-characters-generator.service.ts +42 -0
  98. package/src/z-score.service.ts +24 -0
@@ -0,0 +1,25 @@
1
+ import { Hour } from "./hour.vo";
2
+ import { Minute } from "./minute.vo";
3
+ export type ClockFormatter = (hour: Hour, minute: Minute) => string;
4
+ declare enum ClockFormatterEnum {
5
+ TWENTY_FOUR_HOURS = "TWENTY_FOUR_HOURS",
6
+ TWELVE_HOURS = "TWELVE_HOURS"
7
+ }
8
+ export declare const ClockFormatters: Record<ClockFormatterEnum, ClockFormatter>;
9
+ export declare class Clock {
10
+ private readonly hour;
11
+ private readonly minute;
12
+ private readonly formatter;
13
+ constructor(hour: Hour, minute: Minute, formatter?: ClockFormatter);
14
+ get(formatter?: ClockFormatter): {
15
+ raw: {
16
+ hour: number;
17
+ minute: number;
18
+ };
19
+ formatted: string;
20
+ };
21
+ equals(another: Clock): boolean;
22
+ isAfter(another: Clock): boolean;
23
+ isBefore(another: Clock): boolean;
24
+ }
25
+ export {};
@@ -0,0 +1,45 @@
1
+ import { HourFormatters } from "./hour.vo";
2
+ var ClockFormatterEnum;
3
+ (function (ClockFormatterEnum) {
4
+ ClockFormatterEnum["TWENTY_FOUR_HOURS"] = "TWENTY_FOUR_HOURS";
5
+ ClockFormatterEnum["TWELVE_HOURS"] = "TWELVE_HOURS";
6
+ })(ClockFormatterEnum || (ClockFormatterEnum = {}));
7
+ export const ClockFormatters = {
8
+ TWENTY_FOUR_HOURS: (hour, minute) => `${hour.get().formatted}:${minute.get().formatted}`,
9
+ TWELVE_HOURS: (hour, minute) => `${hour.get(HourFormatters.TWELVE_HOURS).formatted}:${minute.get().formatted}`,
10
+ };
11
+ export class Clock {
12
+ constructor(hour, minute, formatter) {
13
+ this.hour = hour;
14
+ this.minute = minute;
15
+ this.formatter = formatter ?? ClockFormatters.TWENTY_FOUR_HOURS;
16
+ }
17
+ get(formatter) {
18
+ const format = formatter ?? this.formatter;
19
+ return {
20
+ raw: { hour: this.hour.get().raw, minute: this.minute.get().raw },
21
+ formatted: format(this.hour, this.minute),
22
+ };
23
+ }
24
+ equals(another) {
25
+ return (this.hour.get().raw === another.get().raw.hour && this.minute.get().raw === another.get().raw.minute);
26
+ }
27
+ isAfter(another) {
28
+ if (this.hour.get().raw > another.hour.get().raw) {
29
+ return true;
30
+ }
31
+ if (this.hour.get().raw === another.hour.get().raw && this.minute.get().raw > another.minute.get().raw) {
32
+ return true;
33
+ }
34
+ return false;
35
+ }
36
+ isBefore(another) {
37
+ if (this.hour.get().raw < another.hour.get().raw) {
38
+ return true;
39
+ }
40
+ if (this.hour.get().raw === another.hour.get().raw && this.minute.get().raw < another.minute.get().raw) {
41
+ return true;
42
+ }
43
+ return false;
44
+ }
45
+ }
@@ -0,0 +1,29 @@
1
+ export declare class Node<T> {
2
+ data: T;
3
+ prev: Node<T> | null;
4
+ next: Node<T> | null;
5
+ constructor(data: Node<T>["data"]);
6
+ forward(n: number): Node<T> | null;
7
+ backward(n: number): Node<T> | null;
8
+ }
9
+ export declare class DoublyLinkedList<T> {
10
+ static EMPTY_SIZE: number;
11
+ private size;
12
+ private head;
13
+ private tail;
14
+ getSize(): DoublyLinkedList<T>["size"];
15
+ isEmpty(): boolean;
16
+ getHead(): DoublyLinkedList<T>["head"];
17
+ getTail(): DoublyLinkedList<T>["tail"];
18
+ append(node: Node<T>): void;
19
+ prepend(node: Node<T>): void;
20
+ clear(): void;
21
+ remove(node: Node<T>): void;
22
+ insertAfter(node: Node<T>, target: Node<T>): void;
23
+ insertBefore(node: Node<T>, target: Node<T>): void;
24
+ find(callback: (node: Node<T>) => boolean): Node<T> | null;
25
+ reverse(): void;
26
+ toArray(): Node<T>[];
27
+ static fromArray<T>(array: T[]): DoublyLinkedList<T>;
28
+ [Symbol.iterator](): IterableIterator<Node<T>>;
29
+ }
@@ -0,0 +1,148 @@
1
+ export class Node {
2
+ constructor(data) {
3
+ this.prev = null;
4
+ this.next = null;
5
+ this.data = data;
6
+ }
7
+ forward(n) {
8
+ let currentNode = this;
9
+ for (let i = 0; i < n; i++) {
10
+ if (currentNode === null) {
11
+ return currentNode;
12
+ }
13
+ currentNode = currentNode.next;
14
+ }
15
+ return currentNode;
16
+ }
17
+ backward(n) {
18
+ let currentNode = this;
19
+ for (let i = 0; i < n; i++) {
20
+ if (currentNode === null) {
21
+ return currentNode;
22
+ }
23
+ currentNode = currentNode.prev;
24
+ }
25
+ return currentNode;
26
+ }
27
+ }
28
+ export class DoublyLinkedList {
29
+ constructor() {
30
+ this.size = DoublyLinkedList.EMPTY_SIZE;
31
+ this.head = null;
32
+ this.tail = null;
33
+ }
34
+ getSize() {
35
+ return this.size;
36
+ }
37
+ isEmpty() {
38
+ return this.size === 0;
39
+ }
40
+ getHead() {
41
+ return this.head;
42
+ }
43
+ getTail() {
44
+ return this.tail;
45
+ }
46
+ append(node) {
47
+ if (this.head === null || this.tail === null) {
48
+ this.size++;
49
+ this.head = node;
50
+ this.tail = node;
51
+ }
52
+ else {
53
+ this.size++;
54
+ this.tail.next = node;
55
+ node.prev = this.tail;
56
+ this.tail = node;
57
+ }
58
+ }
59
+ prepend(node) {
60
+ if (this.head === null || this.tail === null) {
61
+ this.size++;
62
+ this.head = node;
63
+ this.tail = node;
64
+ }
65
+ else {
66
+ this.size++;
67
+ node.next = this.head;
68
+ this.head.prev = node;
69
+ this.head = node;
70
+ }
71
+ }
72
+ clear() {
73
+ this.size = 0;
74
+ this.head = null;
75
+ this.tail = null;
76
+ }
77
+ remove(node) {
78
+ if (node.prev) {
79
+ node.prev.next = node.next;
80
+ }
81
+ else {
82
+ this.head = node.next;
83
+ }
84
+ if (node.next) {
85
+ node.next.prev = node.prev;
86
+ }
87
+ else {
88
+ this.tail = node.prev;
89
+ }
90
+ this.size--;
91
+ node.prev = null;
92
+ node.next = null;
93
+ }
94
+ insertAfter(node, target) {
95
+ if (target === this.tail) {
96
+ this.append(node);
97
+ }
98
+ else {
99
+ this.size++;
100
+ node.prev = target;
101
+ node.next = target.next;
102
+ // biome-ignore lint: lint/style/noNonNullAssertion
103
+ target.next.prev = node;
104
+ target.next = node;
105
+ }
106
+ }
107
+ insertBefore(node, target) {
108
+ if (target === this.head) {
109
+ this.prepend(node);
110
+ }
111
+ else {
112
+ this.size++;
113
+ node.next = target;
114
+ node.prev = target.prev;
115
+ // biome-ignore lint: lint/style/noNonNullAssertion
116
+ target.prev.next = node;
117
+ target.prev = node;
118
+ }
119
+ }
120
+ find(callback) {
121
+ return Array.from(this).find(callback) ?? null;
122
+ }
123
+ reverse() {
124
+ [this.head, this.tail] = [this.tail, this.head];
125
+ // @ts-ignore
126
+ for (const node of this) {
127
+ [node.prev, node.next] = [node.next, node.prev];
128
+ }
129
+ }
130
+ toArray() {
131
+ return Array.from(this);
132
+ }
133
+ static fromArray(array) {
134
+ const dll = new DoublyLinkedList();
135
+ for (const item of array) {
136
+ dll.append(new Node(item));
137
+ }
138
+ return dll;
139
+ }
140
+ *[Symbol.iterator]() {
141
+ let current = this.head;
142
+ while (current) {
143
+ yield current;
144
+ current = current.next;
145
+ }
146
+ }
147
+ }
148
+ DoublyLinkedList.EMPTY_SIZE = 0;
@@ -0,0 +1,6 @@
1
+ import { z } from "zod/v4";
2
+ export declare const Email: z.ZodEmail;
3
+ export type EmailType = z.infer<typeof Email>;
4
+ export declare class EmailMask {
5
+ static censor(email: EmailType): EmailType;
6
+ }
@@ -0,0 +1,14 @@
1
+ import { z } from "zod/v4";
2
+ export const Email = z.email();
3
+ export class EmailMask {
4
+ static censor(email) {
5
+ const [beforeAt, afterAt] = email.split("@");
6
+ const local = beforeAt;
7
+ const domain = afterAt;
8
+ if (local.length <= 2) {
9
+ return `${"*".repeat(local.length)}@${domain}`;
10
+ }
11
+ const censoredLocal = `${local.at(0)}${"*".repeat(local.length - 2)}${local.at(-1)}`;
12
+ return `${censoredLocal}@${domain}`;
13
+ }
14
+ }
@@ -1,9 +1,9 @@
1
1
  import { z } from "zod/v4";
2
- declare const RevisionValueSchema: z.ZodNumber;
3
- type RevisionValueSchemaType = z.infer<typeof RevisionValueSchema>;
2
+ declare const RevisionValue: z.ZodNumber;
3
+ type RevisionValueType = z.infer<typeof RevisionValue>;
4
4
  type ETagValueType = string;
5
5
  export declare class ETag {
6
- readonly revision: RevisionValueSchemaType;
6
+ readonly revision: RevisionValueType;
7
7
  static HEADER_NAME: string;
8
8
  static IF_MATCH_HEADER_NAME: string;
9
9
  readonly value: ETagValueType;
@@ -12,7 +12,7 @@ export declare class ETag {
12
12
  }
13
13
  export type WeakETagValueType = string;
14
14
  export declare class WeakETag {
15
- readonly revision: RevisionValueSchemaType;
15
+ readonly revision: RevisionValueType;
16
16
  static HEADER_NAME: string;
17
17
  static IF_MATCH_HEADER_NAME: string;
18
18
  readonly value: WeakETagValueType;
package/dist/etags.vo.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { z } from "zod/v4";
2
- const RevisionValueSchema = z.number().int().min(0);
2
+ const RevisionValue = z.number().int().min(0);
3
3
  export class ETag {
4
4
  constructor(revision) {
5
5
  this.revision = revision;
@@ -0,0 +1,11 @@
1
+ import { z } from "zod/v4";
2
+ export declare enum FeatureFlagEnum {
3
+ yes = "yes",
4
+ no = "no"
5
+ }
6
+ export declare const FeatureFlagValue: z.ZodEnum<typeof FeatureFlagEnum>;
7
+ export type FeatureFlagValueType = z.infer<typeof FeatureFlagValue>;
8
+ export declare class FeatureFlag {
9
+ static isEnabled(flag: FeatureFlagValueType): boolean;
10
+ static isDisabled(flag: FeatureFlagValueType): boolean;
11
+ }
@@ -0,0 +1,15 @@
1
+ import { z } from "zod/v4";
2
+ export var FeatureFlagEnum;
3
+ (function (FeatureFlagEnum) {
4
+ FeatureFlagEnum["yes"] = "yes";
5
+ FeatureFlagEnum["no"] = "no";
6
+ })(FeatureFlagEnum || (FeatureFlagEnum = {}));
7
+ export const FeatureFlagValue = z.enum(FeatureFlagEnum);
8
+ export class FeatureFlag {
9
+ static isEnabled(flag) {
10
+ return flag === FeatureFlagEnum.yes;
11
+ }
12
+ static isDisabled(flag) {
13
+ return flag === FeatureFlagEnum.no;
14
+ }
15
+ }
@@ -0,0 +1,17 @@
1
+ import { z } from "zod/v4";
2
+ export type DefaultFilterSchemaType = z.ZodRawShape;
3
+ export type FilterValuesType = Record<string, unknown>;
4
+ export type FilterSchemaType<T extends DefaultFilterSchemaType> = z.ZodObject<T>;
5
+ export type FilterParseConfigType<T extends DefaultFilterSchemaType> = {
6
+ schema: FilterSchemaType<T>;
7
+ values: FilterValuesType;
8
+ };
9
+ export declare class Filter<T extends DefaultFilterSchemaType> {
10
+ private readonly schema;
11
+ constructor(schema: FilterSchemaType<T>);
12
+ parse(values: FilterValuesType): z.core.$InferObjectOutput<T, Record<string, unknown>> | undefined;
13
+ default(): z.core.$InferObjectOutput<T, Record<string, unknown>> | undefined;
14
+ static parse<T extends DefaultFilterSchemaType>(config: FilterParseConfigType<T>): z.core.$InferObjectOutput<T, Record<string, unknown>> | undefined;
15
+ static default<T extends DefaultFilterSchemaType>(config: Omit<FilterParseConfigType<T>, "values">): z.core.$InferObjectOutput<T, Record<string, unknown>> | undefined;
16
+ private static _parse;
17
+ }
@@ -0,0 +1,21 @@
1
+ export class Filter {
2
+ constructor(schema) {
3
+ this.schema = schema;
4
+ }
5
+ parse(values) {
6
+ return Filter._parse({ schema: this.schema, values });
7
+ }
8
+ default() {
9
+ return this.parse({});
10
+ }
11
+ static parse(config) {
12
+ return Filter._parse(config);
13
+ }
14
+ static default(config) {
15
+ return Filter._parse({ schema: config.schema, values: {} });
16
+ }
17
+ static _parse(config) {
18
+ const result = config.schema.safeParse(config.values);
19
+ return result.success ? result.data : undefined;
20
+ }
21
+ }
@@ -0,0 +1,24 @@
1
+ export type HourFormatter = (value: Hour["value"]) => string;
2
+ export declare enum HourFormatterEnum {
3
+ TWENTY_FOUR_HOURS = "TWENTY_FOUR_HOURS",
4
+ TWENTY_FOUR_HOURS_WO_PADDING = "TWENTY_FOUR_HOURS_WO_PADDING",
5
+ AM_PM = "AM_PM",
6
+ TWELVE_HOURS = "TWELVE_HOURS",
7
+ TWELVE_HOURS_WO_PADDING = "TWELVE_HOURS_WO_PADDING"
8
+ }
9
+ export declare const HourFormatters: Record<HourFormatterEnum, HourFormatter>;
10
+ export declare class Hour {
11
+ private readonly value;
12
+ private readonly formatter;
13
+ static readonly ZERO: Hour;
14
+ static readonly MAX: Hour;
15
+ constructor(candidate: number, formatter?: HourFormatter);
16
+ get(formatter?: HourFormatter): {
17
+ raw: number;
18
+ formatted: string;
19
+ };
20
+ equals(another: Hour): boolean;
21
+ isAfter(another: Hour): boolean;
22
+ isBefore(another: Hour): boolean;
23
+ static list(formatter?: HourFormatter): Hour[];
24
+ }
@@ -0,0 +1,52 @@
1
+ export var HourFormatterEnum;
2
+ (function (HourFormatterEnum) {
3
+ HourFormatterEnum["TWENTY_FOUR_HOURS"] = "TWENTY_FOUR_HOURS";
4
+ HourFormatterEnum["TWENTY_FOUR_HOURS_WO_PADDING"] = "TWENTY_FOUR_HOURS_WO_PADDING";
5
+ HourFormatterEnum["AM_PM"] = "AM_PM";
6
+ HourFormatterEnum["TWELVE_HOURS"] = "TWELVE_HOURS";
7
+ HourFormatterEnum["TWELVE_HOURS_WO_PADDING"] = "TWELVE_HOURS_WO_PADDING";
8
+ })(HourFormatterEnum || (HourFormatterEnum = {}));
9
+ export const HourFormatters = {
10
+ TWENTY_FOUR_HOURS: (value) => value.toString().padStart(2, "0"),
11
+ TWENTY_FOUR_HOURS_WO_PADDING: (value) => value.toString(),
12
+ AM_PM: (value) => {
13
+ if (value < 12)
14
+ return `${value.toString()} a.m.`;
15
+ return `${value.toString()} p.m.`;
16
+ },
17
+ TWELVE_HOURS: (value) => (value % 12).toString().padStart(2, "0"),
18
+ TWELVE_HOURS_WO_PADDING: (value) => (value % 12).toString(),
19
+ };
20
+ export class Hour {
21
+ constructor(candidate, formatter) {
22
+ if (!Number.isInteger(candidate)) {
23
+ throw new Error("Invalid hour");
24
+ }
25
+ if (candidate < 0) {
26
+ throw new Error("Invalid hour");
27
+ }
28
+ if (candidate >= 24) {
29
+ throw new Error("Invalid hour");
30
+ }
31
+ this.value = candidate;
32
+ this.formatter = formatter ?? HourFormatters.TWENTY_FOUR_HOURS;
33
+ }
34
+ get(formatter) {
35
+ const format = formatter ?? this.formatter;
36
+ return { raw: this.value, formatted: format(this.value) };
37
+ }
38
+ equals(another) {
39
+ return this.value === another.get().raw;
40
+ }
41
+ isAfter(another) {
42
+ return this.value > another.get().raw;
43
+ }
44
+ isBefore(another) {
45
+ return this.value < another.get().raw;
46
+ }
47
+ static list(formatter) {
48
+ return Array.from({ length: 24 }).map((_, index) => new Hour(index, formatter));
49
+ }
50
+ }
51
+ Hour.ZERO = new Hour(0);
52
+ Hour.MAX = new Hour(23);
@@ -0,0 +1,5 @@
1
+ import { z } from "zod/v4";
2
+ export declare const Width: z.ZodNumber;
3
+ export type WidthType = z.infer<typeof Width>;
4
+ export declare const Height: z.ZodNumber;
5
+ export type HeightType = z.infer<typeof Height>;
@@ -0,0 +1,3 @@
1
+ import { z } from "zod/v4";
2
+ export const Width = z.number().int().positive().max(10000);
3
+ export const Height = z.number().int().positive().max(10000);
package/dist/index.d.ts CHANGED
@@ -1,21 +1,48 @@
1
1
  export * from "./api-key.vo";
2
2
  export * from "./build-version.vo";
3
+ export * from "./clock.vo";
3
4
  export * from "./date-calculator.service";
4
5
  export * from "./date-formatter.service";
5
6
  export * from "./dates-of-the-week.vo";
7
+ export * from "./dll.service";
8
+ export * from "./email-mask.service";
6
9
  export * from "./etags.vo";
10
+ export * from "./feature-flag.vo";
11
+ export * from "./filter.vo";
12
+ export * from "./hour.vo";
13
+ export * from "./image.vo";
7
14
  export * from "./language.vo";
15
+ export * from "./leap-year-checker.service";
16
+ export * from "./mean.service";
17
+ export * from "./mime-types.vo";
8
18
  export * from "./mime.vo";
19
+ export * from "./min-max-scaler.service";
20
+ export * from "./minute.vo";
21
+ export * from "./money.vo";
9
22
  export * from "./noop.service";
23
+ export * from "./outlier-detector.service";
10
24
  export * from "./package-version.vo";
25
+ export * from "./pagination.service";
26
+ export * from "./percentage.service";
27
+ export * from "./population-standard-deviation.service";
28
+ export * from "./random.service";
11
29
  export * from "./rate-limiter.service";
12
30
  export * from "./relative-date.vo";
31
+ export * from "./reordering.service";
32
+ export * from "./revision.vo";
13
33
  export * from "./rounding.service";
34
+ export * from "./simple-linear-regression.service";
14
35
  export * from "./size.vo";
15
36
  export * from "./sleep.service";
37
+ export * from "./stepper.service";
16
38
  export * from "./stopwatch.service";
39
+ export * from "./streak-calculator.service";
40
+ export * from "./sum.service";
41
+ export * from "./thousands-separator.service";
17
42
  export * from "./time-zone-offset-value.vo";
18
43
  export * from "./time.service";
19
44
  export * from "./timestamp.vo";
20
45
  export * from "./timezone.vo";
21
46
  export * from "./ts-utils";
47
+ export * from "./visually-unambiguous-characters-generator.service";
48
+ export * from "./z-score.service";
package/dist/index.js CHANGED
@@ -1,21 +1,48 @@
1
1
  export * from "./api-key.vo";
2
2
  export * from "./build-version.vo";
3
+ export * from "./clock.vo";
3
4
  export * from "./date-calculator.service";
4
5
  export * from "./date-formatter.service";
5
6
  export * from "./dates-of-the-week.vo";
7
+ export * from "./dll.service";
8
+ export * from "./email-mask.service";
6
9
  export * from "./etags.vo";
10
+ export * from "./feature-flag.vo";
11
+ export * from "./filter.vo";
12
+ export * from "./hour.vo";
13
+ export * from "./image.vo";
7
14
  export * from "./language.vo";
15
+ export * from "./leap-year-checker.service";
16
+ export * from "./mean.service";
17
+ export * from "./mime-types.vo";
8
18
  export * from "./mime.vo";
19
+ export * from "./min-max-scaler.service";
20
+ export * from "./minute.vo";
21
+ export * from "./money.vo";
9
22
  export * from "./noop.service";
23
+ export * from "./outlier-detector.service";
10
24
  export * from "./package-version.vo";
25
+ export * from "./pagination.service";
26
+ export * from "./percentage.service";
27
+ export * from "./population-standard-deviation.service";
28
+ export * from "./random.service";
11
29
  export * from "./rate-limiter.service";
12
30
  export * from "./relative-date.vo";
31
+ export * from "./reordering.service";
32
+ export * from "./revision.vo";
13
33
  export * from "./rounding.service";
34
+ export * from "./simple-linear-regression.service";
14
35
  export * from "./size.vo";
15
36
  export * from "./sleep.service";
37
+ export * from "./stepper.service";
16
38
  export * from "./stopwatch.service";
39
+ export * from "./streak-calculator.service";
40
+ export * from "./sum.service";
41
+ export * from "./thousands-separator.service";
17
42
  export * from "./time-zone-offset-value.vo";
18
43
  export * from "./time.service";
19
44
  export * from "./timestamp.vo";
20
45
  export * from "./timezone.vo";
21
46
  export * from "./ts-utils";
47
+ export * from "./visually-unambiguous-characters-generator.service";
48
+ export * from "./z-score.service";
@@ -0,0 +1,4 @@
1
+ export declare class LeapYearChecker {
2
+ static isLeapYear(year: number): boolean;
3
+ static isCurrentYearLeapYear(): boolean;
4
+ }
@@ -0,0 +1,9 @@
1
+ export class LeapYearChecker {
2
+ static isLeapYear(year) {
3
+ return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
4
+ }
5
+ static isCurrentYearLeapYear() {
6
+ const year = new Date().getFullYear();
7
+ return LeapYearChecker.isLeapYear(year);
8
+ }
9
+ }
@@ -0,0 +1,4 @@
1
+ import { RoundingStrategy } from "./rounding.service";
2
+ export declare class Mean {
3
+ static calculate(values: number[], rounding?: RoundingStrategy): number;
4
+ }
@@ -0,0 +1,11 @@
1
+ import { RoundToDecimal } from "./rounding.service";
2
+ import { Sum } from "./sum.service";
3
+ export class Mean {
4
+ static calculate(values, rounding = new RoundToDecimal(2)) {
5
+ if (values.length === 0) {
6
+ throw new Error("Values should not be empty");
7
+ }
8
+ const mean = Sum.of(values) / values.length;
9
+ return rounding.round(mean);
10
+ }
11
+ }
@@ -0,0 +1,2 @@
1
+ import type { MimeRawType } from "./mime.vo";
2
+ export declare const MIME_TYPES: Record<string, MimeRawType[]>;
@@ -0,0 +1,7 @@
1
+ export const MIME_TYPES = {
2
+ wildcard: ["*/*"],
3
+ jpeg: ["image/jpeg"],
4
+ png: ["image/png"],
5
+ wav: ["audio/x-wav", "audio/wav"],
6
+ mp4: ["video/mp4"],
7
+ };
package/dist/mime.vo.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- type MimeRawType = string;
1
+ export type MimeRawType = string;
2
2
  type MimeTypeType = string;
3
3
  type MimeSubtypeType = string;
4
4
  export declare class Mime {
@@ -0,0 +1,36 @@
1
+ import { RoundingStrategy } from "./rounding.service";
2
+ type MinMaxScalerValueType = number;
3
+ type MinMaxScalerConfigType = {
4
+ min: MinMaxScalerValueType;
5
+ max: MinMaxScalerValueType;
6
+ bound?: {
7
+ lower: MinMaxScalerValueType;
8
+ upper: MinMaxScalerValueType;
9
+ };
10
+ rounding?: RoundingStrategy;
11
+ };
12
+ export declare class MinMaxScaler {
13
+ private readonly min;
14
+ private readonly max;
15
+ private readonly lower;
16
+ private readonly upper;
17
+ private readonly rounding;
18
+ constructor(config: MinMaxScalerConfigType);
19
+ scale(value: MinMaxScalerValueType): {
20
+ original: number;
21
+ scaled: number;
22
+ isMin: boolean;
23
+ isMax: boolean;
24
+ };
25
+ descale(scaled: MinMaxScalerValueType): {
26
+ original: number;
27
+ scaled: number;
28
+ isLowerBound: boolean;
29
+ isUpperBound: boolean;
30
+ };
31
+ static getMinMax(values: MinMaxScalerValueType[]): {
32
+ min: number;
33
+ max: number;
34
+ };
35
+ }
36
+ export {};