@tspro/ts-utils-lib 1.1.0 → 1.2.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.2.0] - 2025-07-17
4
+ ### Added
5
+ - Assert.assertEnum(...)
6
+
3
7
  ## [1.1.0] - 2025-07-12
4
8
  ### Added
5
9
  - Utils.Obj.isObject
package/dist/index.d.mts CHANGED
@@ -11,20 +11,20 @@ declare function getRangeArray(start: number, end: number): number[];
11
11
  declare function arrayContains<T extends unknown>(arg: T[], item: T): boolean;
12
12
  declare function chunckArray<A>(arr: ReadonlyArray<A>, chunckSize: number): A[][];
13
13
 
14
- declare const index$6_arrayContains: typeof arrayContains;
15
- declare const index$6_chunckArray: typeof chunckArray;
16
- declare const index$6_duplicate: typeof duplicate;
17
- declare const index$6_fillArray: typeof fillArray;
18
- declare const index$6_getRangeArray: typeof getRangeArray;
19
- declare const index$6_getSequenceArray: typeof getSequenceArray;
20
- declare const index$6_isArray: typeof isArray;
21
- declare const index$6_mapRangeArray: typeof mapRangeArray;
22
- declare const index$6_mapSequenceArray: typeof mapSequenceArray;
23
- declare const index$6_removeDuplicates: typeof removeDuplicates;
24
- declare const index$6_removeDuplicatesCmp: typeof removeDuplicatesCmp;
25
- declare const index$6_toArray: typeof toArray;
26
- declare namespace index$6 {
27
- export { index$6_arrayContains as arrayContains, index$6_chunckArray as chunckArray, index$6_duplicate as duplicate, index$6_fillArray as fillArray, index$6_getRangeArray as getRangeArray, index$6_getSequenceArray as getSequenceArray, index$6_isArray as isArray, index$6_mapRangeArray as mapRangeArray, index$6_mapSequenceArray as mapSequenceArray, index$6_removeDuplicates as removeDuplicates, index$6_removeDuplicatesCmp as removeDuplicatesCmp, index$6_toArray as toArray };
14
+ declare const index$7_arrayContains: typeof arrayContains;
15
+ declare const index$7_chunckArray: typeof chunckArray;
16
+ declare const index$7_duplicate: typeof duplicate;
17
+ declare const index$7_fillArray: typeof fillArray;
18
+ declare const index$7_getRangeArray: typeof getRangeArray;
19
+ declare const index$7_getSequenceArray: typeof getSequenceArray;
20
+ declare const index$7_isArray: typeof isArray;
21
+ declare const index$7_mapRangeArray: typeof mapRangeArray;
22
+ declare const index$7_mapSequenceArray: typeof mapSequenceArray;
23
+ declare const index$7_removeDuplicates: typeof removeDuplicates;
24
+ declare const index$7_removeDuplicatesCmp: typeof removeDuplicatesCmp;
25
+ declare const index$7_toArray: typeof toArray;
26
+ declare namespace index$7 {
27
+ export { index$7_arrayContains as arrayContains, index$7_chunckArray as chunckArray, index$7_duplicate as duplicate, index$7_fillArray as fillArray, index$7_getRangeArray as getRangeArray, index$7_getSequenceArray as getSequenceArray, index$7_isArray as isArray, index$7_mapRangeArray as mapRangeArray, index$7_mapSequenceArray as mapSequenceArray, index$7_removeDuplicates as removeDuplicates, index$7_removeDuplicatesCmp as removeDuplicatesCmp, index$7_toArray as toArray };
28
28
  }
29
29
 
30
30
  interface CSSProperties {
@@ -73,28 +73,28 @@ declare function getDimension(style?: CSSProperties): {
73
73
  declare function styleLayoutChanged(style1?: CSSProperties, style2?: CSSProperties): boolean;
74
74
  declare function getCanvasTextWidth(text: string, font: string): number;
75
75
 
76
- type index$5_CSSProperties = CSSProperties;
77
- declare const index$5_addClass: typeof addClass;
78
- declare const index$5_appendTo: typeof appendTo;
79
- declare const index$5_getButton: typeof getButton;
80
- declare const index$5_getCanvas: typeof getCanvas;
81
- declare const index$5_getCanvasTextWidth: typeof getCanvasTextWidth;
82
- declare const index$5_getDimension: typeof getDimension;
83
- declare const index$5_getHeight: typeof getHeight;
84
- declare const index$5_getOffset: typeof getOffset;
85
- declare const index$5_getPadding: typeof getPadding;
86
- declare const index$5_getWidth: typeof getWidth;
87
- declare const index$5_hasClass: typeof hasClass;
88
- declare const index$5_removeClass: typeof removeClass;
89
- declare const index$5_removeFromParent: typeof removeFromParent;
90
- declare const index$5_setHeight: typeof setHeight;
91
- declare const index$5_setOffset: typeof setOffset;
92
- declare const index$5_setRect: typeof setRect;
93
- declare const index$5_setVisibility: typeof setVisibility;
94
- declare const index$5_setWidth: typeof setWidth;
95
- declare const index$5_styleLayoutChanged: typeof styleLayoutChanged;
96
- declare namespace index$5 {
97
- export { type index$5_CSSProperties as CSSProperties, index$5_addClass as addClass, index$5_appendTo as appendTo, index$5_getButton as getButton, index$5_getCanvas as getCanvas, index$5_getCanvasTextWidth as getCanvasTextWidth, index$5_getDimension as getDimension, index$5_getHeight as getHeight, index$5_getOffset as getOffset, index$5_getPadding as getPadding, index$5_getWidth as getWidth, index$5_hasClass as hasClass, index$5_removeClass as removeClass, index$5_removeFromParent as removeFromParent, index$5_setHeight as setHeight, index$5_setOffset as setOffset, index$5_setRect as setRect, index$5_setVisibility as setVisibility, index$5_setWidth as setWidth, index$5_styleLayoutChanged as styleLayoutChanged };
76
+ type index$6_CSSProperties = CSSProperties;
77
+ declare const index$6_addClass: typeof addClass;
78
+ declare const index$6_appendTo: typeof appendTo;
79
+ declare const index$6_getButton: typeof getButton;
80
+ declare const index$6_getCanvas: typeof getCanvas;
81
+ declare const index$6_getCanvasTextWidth: typeof getCanvasTextWidth;
82
+ declare const index$6_getDimension: typeof getDimension;
83
+ declare const index$6_getHeight: typeof getHeight;
84
+ declare const index$6_getOffset: typeof getOffset;
85
+ declare const index$6_getPadding: typeof getPadding;
86
+ declare const index$6_getWidth: typeof getWidth;
87
+ declare const index$6_hasClass: typeof hasClass;
88
+ declare const index$6_removeClass: typeof removeClass;
89
+ declare const index$6_removeFromParent: typeof removeFromParent;
90
+ declare const index$6_setHeight: typeof setHeight;
91
+ declare const index$6_setOffset: typeof setOffset;
92
+ declare const index$6_setRect: typeof setRect;
93
+ declare const index$6_setVisibility: typeof setVisibility;
94
+ declare const index$6_setWidth: typeof setWidth;
95
+ declare const index$6_styleLayoutChanged: typeof styleLayoutChanged;
96
+ declare namespace index$6 {
97
+ export { type index$6_CSSProperties as CSSProperties, index$6_addClass as addClass, index$6_appendTo as appendTo, index$6_getButton as getButton, index$6_getCanvas as getCanvas, index$6_getCanvasTextWidth as getCanvasTextWidth, index$6_getDimension as getDimension, index$6_getHeight as getHeight, index$6_getOffset as getOffset, index$6_getPadding as getPadding, index$6_getWidth as getWidth, index$6_hasClass as hasClass, index$6_removeClass as removeClass, index$6_removeFromParent as removeFromParent, index$6_setHeight as setHeight, index$6_setOffset as setOffset, index$6_setRect as setRect, index$6_setVisibility as setVisibility, index$6_setWidth as setWidth, index$6_styleLayoutChanged as styleLayoutChanged };
98
98
  }
99
99
 
100
100
  type EnumObject = {
@@ -105,18 +105,18 @@ type EnumValue<E extends EnumObject> = E extends {
105
105
  } ? V : never;
106
106
  declare function getEnumValues<E extends EnumObject>(e: E): Array<EnumValue<E>>;
107
107
 
108
- type index$4_EnumObject = EnumObject;
109
- type index$4_EnumValue<E extends EnumObject> = EnumValue<E>;
110
- declare const index$4_getEnumValues: typeof getEnumValues;
111
- declare namespace index$4 {
112
- export { type index$4_EnumObject as EnumObject, type index$4_EnumValue as EnumValue, index$4_getEnumValues as getEnumValues };
108
+ type index$5_EnumObject = EnumObject;
109
+ type index$5_EnumValue<E extends EnumObject> = EnumValue<E>;
110
+ declare const index$5_getEnumValues: typeof getEnumValues;
111
+ declare namespace index$5 {
112
+ export { type index$5_EnumObject as EnumObject, type index$5_EnumValue as EnumValue, index$5_getEnumValues as getEnumValues };
113
113
  }
114
114
 
115
115
  declare function getMapKeys<K, V>(map: Map<K, V>): K[];
116
116
 
117
- declare const index$3_getMapKeys: typeof getMapKeys;
118
- declare namespace index$3 {
119
- export { index$3_getMapKeys as getMapKeys };
117
+ declare const index$4_getMapKeys: typeof getMapKeys;
118
+ declare namespace index$4 {
119
+ export { index$4_getMapKeys as getMapKeys };
120
120
  }
121
121
 
122
122
  declare function isInteger(n: unknown): n is number;
@@ -140,25 +140,25 @@ declare function calcNormal(x1: number, y1: number, x2: number, y2: number): {
140
140
  };
141
141
  declare function sum(arr: number[]): number;
142
142
 
143
- declare const index$2_calcNormal: typeof calcNormal;
144
- declare const index$2_clamp: typeof clamp;
145
- declare const index$2_interpolateCoord: typeof interpolateCoord;
146
- declare const index$2_interpolateY: typeof interpolateY;
147
- declare const index$2_isInteger: typeof isInteger;
148
- declare const index$2_linearToDecibels: typeof linearToDecibels;
149
- declare const index$2_mod: typeof mod;
150
- declare const index$2_romanize: typeof romanize;
151
- declare const index$2_sum: typeof sum;
152
- declare const index$2_toOrdinalNumber: typeof toOrdinalNumber;
153
- declare namespace index$2 {
154
- export { index$2_calcNormal as calcNormal, index$2_clamp as clamp, index$2_interpolateCoord as interpolateCoord, index$2_interpolateY as interpolateY, index$2_isInteger as isInteger, index$2_linearToDecibels as linearToDecibels, index$2_mod as mod, index$2_romanize as romanize, index$2_sum as sum, index$2_toOrdinalNumber as toOrdinalNumber };
143
+ declare const index$3_calcNormal: typeof calcNormal;
144
+ declare const index$3_clamp: typeof clamp;
145
+ declare const index$3_interpolateCoord: typeof interpolateCoord;
146
+ declare const index$3_interpolateY: typeof interpolateY;
147
+ declare const index$3_isInteger: typeof isInteger;
148
+ declare const index$3_linearToDecibels: typeof linearToDecibels;
149
+ declare const index$3_mod: typeof mod;
150
+ declare const index$3_romanize: typeof romanize;
151
+ declare const index$3_sum: typeof sum;
152
+ declare const index$3_toOrdinalNumber: typeof toOrdinalNumber;
153
+ declare namespace index$3 {
154
+ export { index$3_calcNormal as calcNormal, index$3_clamp as clamp, index$3_interpolateCoord as interpolateCoord, index$3_interpolateY as interpolateY, index$3_isInteger as isInteger, index$3_linearToDecibels as linearToDecibels, index$3_mod as mod, index$3_romanize as romanize, index$3_sum as sum, index$3_toOrdinalNumber as toOrdinalNumber };
155
155
  }
156
156
 
157
157
  declare function isObject(value: unknown): value is Record<string, unknown>;
158
158
 
159
- declare const index$1_isObject: typeof isObject;
160
- declare namespace index$1 {
161
- export { index$1_isObject as isObject };
159
+ declare const index$2_isObject: typeof isObject;
160
+ declare namespace index$2 {
161
+ export { index$2_isObject as isObject };
162
162
  }
163
163
 
164
164
  /**
@@ -207,25 +207,26 @@ declare function removeAt(str: string, pos: number, removeCount: number): string
207
207
  */
208
208
  declare function makeSentenceFromPascal(PascalString: string): string;
209
209
 
210
- declare const index_chunkString: typeof chunkString;
211
- declare const index_insertAt: typeof insertAt;
212
- declare const index_makeSentenceFromPascal: typeof makeSentenceFromPascal;
213
- declare const index_removeAt: typeof removeAt;
214
- declare const index_repeatString: typeof repeatString;
215
- declare const index_replaceAt: typeof replaceAt;
216
- declare const index_toCharArray: typeof toCharArray;
217
- declare namespace index {
218
- export { index_chunkString as chunkString, index_insertAt as insertAt, index_makeSentenceFromPascal as makeSentenceFromPascal, index_removeAt as removeAt, index_repeatString as repeatString, index_replaceAt as replaceAt, index_toCharArray as toCharArray };
210
+ declare const index$1_chunkString: typeof chunkString;
211
+ declare const index$1_insertAt: typeof insertAt;
212
+ declare const index$1_makeSentenceFromPascal: typeof makeSentenceFromPascal;
213
+ declare const index$1_removeAt: typeof removeAt;
214
+ declare const index$1_repeatString: typeof repeatString;
215
+ declare const index$1_replaceAt: typeof replaceAt;
216
+ declare const index$1_toCharArray: typeof toCharArray;
217
+ declare namespace index$1 {
218
+ export { index$1_chunkString as chunkString, index$1_insertAt as insertAt, index$1_makeSentenceFromPascal as makeSentenceFromPascal, index$1_removeAt as removeAt, index$1_repeatString as repeatString, index$1_replaceAt as replaceAt, index$1_toCharArray as toCharArray };
219
219
  }
220
220
 
221
- declare namespace exportUtils {
222
- export { index$6 as Arr, index$5 as Dom, index$4 as Enum, index$3 as Map, index$2 as Math, index$1 as Obj, index as Str };
221
+ declare namespace index {
222
+ export { index$7 as Arr, index$6 as Dom, index$5 as Enum, index$4 as Map, index$3 as Math, index$2 as Obj, index$1 as Str };
223
223
  }
224
224
 
225
225
  declare namespace Assert {
226
226
  type ErrorConstructor = new (msg: string) => Error;
227
227
  function setErrorClass(ec?: ErrorConstructor): void;
228
228
  function assert<T>(a: T, userMsg?: string): void;
229
+ function assertEnum<E extends Record<string, string | number>>(value: unknown, enumObj: E, name?: string): asserts value is E[keyof E];
229
230
  function interrupt(userMsg?: string): never;
230
231
  function int(a: unknown, userMsg?: string): number;
231
232
  function eq<T>(a: T, b: T, userMsg?: string): T;
@@ -344,4 +345,4 @@ declare class SmallIntCache<V> {
344
345
  clear(): void;
345
346
  }
346
347
 
347
- export { Assert, Cookies, Device, LRUCache, SmallIntCache, Stack, exportUtils as Utils, Vec2 };
348
+ export { Assert, Cookies, Device, LRUCache, SmallIntCache, Stack, index as Utils, Vec2 };
package/dist/index.d.ts CHANGED
@@ -11,20 +11,20 @@ declare function getRangeArray(start: number, end: number): number[];
11
11
  declare function arrayContains<T extends unknown>(arg: T[], item: T): boolean;
12
12
  declare function chunckArray<A>(arr: ReadonlyArray<A>, chunckSize: number): A[][];
13
13
 
14
- declare const index$6_arrayContains: typeof arrayContains;
15
- declare const index$6_chunckArray: typeof chunckArray;
16
- declare const index$6_duplicate: typeof duplicate;
17
- declare const index$6_fillArray: typeof fillArray;
18
- declare const index$6_getRangeArray: typeof getRangeArray;
19
- declare const index$6_getSequenceArray: typeof getSequenceArray;
20
- declare const index$6_isArray: typeof isArray;
21
- declare const index$6_mapRangeArray: typeof mapRangeArray;
22
- declare const index$6_mapSequenceArray: typeof mapSequenceArray;
23
- declare const index$6_removeDuplicates: typeof removeDuplicates;
24
- declare const index$6_removeDuplicatesCmp: typeof removeDuplicatesCmp;
25
- declare const index$6_toArray: typeof toArray;
26
- declare namespace index$6 {
27
- export { index$6_arrayContains as arrayContains, index$6_chunckArray as chunckArray, index$6_duplicate as duplicate, index$6_fillArray as fillArray, index$6_getRangeArray as getRangeArray, index$6_getSequenceArray as getSequenceArray, index$6_isArray as isArray, index$6_mapRangeArray as mapRangeArray, index$6_mapSequenceArray as mapSequenceArray, index$6_removeDuplicates as removeDuplicates, index$6_removeDuplicatesCmp as removeDuplicatesCmp, index$6_toArray as toArray };
14
+ declare const index$7_arrayContains: typeof arrayContains;
15
+ declare const index$7_chunckArray: typeof chunckArray;
16
+ declare const index$7_duplicate: typeof duplicate;
17
+ declare const index$7_fillArray: typeof fillArray;
18
+ declare const index$7_getRangeArray: typeof getRangeArray;
19
+ declare const index$7_getSequenceArray: typeof getSequenceArray;
20
+ declare const index$7_isArray: typeof isArray;
21
+ declare const index$7_mapRangeArray: typeof mapRangeArray;
22
+ declare const index$7_mapSequenceArray: typeof mapSequenceArray;
23
+ declare const index$7_removeDuplicates: typeof removeDuplicates;
24
+ declare const index$7_removeDuplicatesCmp: typeof removeDuplicatesCmp;
25
+ declare const index$7_toArray: typeof toArray;
26
+ declare namespace index$7 {
27
+ export { index$7_arrayContains as arrayContains, index$7_chunckArray as chunckArray, index$7_duplicate as duplicate, index$7_fillArray as fillArray, index$7_getRangeArray as getRangeArray, index$7_getSequenceArray as getSequenceArray, index$7_isArray as isArray, index$7_mapRangeArray as mapRangeArray, index$7_mapSequenceArray as mapSequenceArray, index$7_removeDuplicates as removeDuplicates, index$7_removeDuplicatesCmp as removeDuplicatesCmp, index$7_toArray as toArray };
28
28
  }
29
29
 
30
30
  interface CSSProperties {
@@ -73,28 +73,28 @@ declare function getDimension(style?: CSSProperties): {
73
73
  declare function styleLayoutChanged(style1?: CSSProperties, style2?: CSSProperties): boolean;
74
74
  declare function getCanvasTextWidth(text: string, font: string): number;
75
75
 
76
- type index$5_CSSProperties = CSSProperties;
77
- declare const index$5_addClass: typeof addClass;
78
- declare const index$5_appendTo: typeof appendTo;
79
- declare const index$5_getButton: typeof getButton;
80
- declare const index$5_getCanvas: typeof getCanvas;
81
- declare const index$5_getCanvasTextWidth: typeof getCanvasTextWidth;
82
- declare const index$5_getDimension: typeof getDimension;
83
- declare const index$5_getHeight: typeof getHeight;
84
- declare const index$5_getOffset: typeof getOffset;
85
- declare const index$5_getPadding: typeof getPadding;
86
- declare const index$5_getWidth: typeof getWidth;
87
- declare const index$5_hasClass: typeof hasClass;
88
- declare const index$5_removeClass: typeof removeClass;
89
- declare const index$5_removeFromParent: typeof removeFromParent;
90
- declare const index$5_setHeight: typeof setHeight;
91
- declare const index$5_setOffset: typeof setOffset;
92
- declare const index$5_setRect: typeof setRect;
93
- declare const index$5_setVisibility: typeof setVisibility;
94
- declare const index$5_setWidth: typeof setWidth;
95
- declare const index$5_styleLayoutChanged: typeof styleLayoutChanged;
96
- declare namespace index$5 {
97
- export { type index$5_CSSProperties as CSSProperties, index$5_addClass as addClass, index$5_appendTo as appendTo, index$5_getButton as getButton, index$5_getCanvas as getCanvas, index$5_getCanvasTextWidth as getCanvasTextWidth, index$5_getDimension as getDimension, index$5_getHeight as getHeight, index$5_getOffset as getOffset, index$5_getPadding as getPadding, index$5_getWidth as getWidth, index$5_hasClass as hasClass, index$5_removeClass as removeClass, index$5_removeFromParent as removeFromParent, index$5_setHeight as setHeight, index$5_setOffset as setOffset, index$5_setRect as setRect, index$5_setVisibility as setVisibility, index$5_setWidth as setWidth, index$5_styleLayoutChanged as styleLayoutChanged };
76
+ type index$6_CSSProperties = CSSProperties;
77
+ declare const index$6_addClass: typeof addClass;
78
+ declare const index$6_appendTo: typeof appendTo;
79
+ declare const index$6_getButton: typeof getButton;
80
+ declare const index$6_getCanvas: typeof getCanvas;
81
+ declare const index$6_getCanvasTextWidth: typeof getCanvasTextWidth;
82
+ declare const index$6_getDimension: typeof getDimension;
83
+ declare const index$6_getHeight: typeof getHeight;
84
+ declare const index$6_getOffset: typeof getOffset;
85
+ declare const index$6_getPadding: typeof getPadding;
86
+ declare const index$6_getWidth: typeof getWidth;
87
+ declare const index$6_hasClass: typeof hasClass;
88
+ declare const index$6_removeClass: typeof removeClass;
89
+ declare const index$6_removeFromParent: typeof removeFromParent;
90
+ declare const index$6_setHeight: typeof setHeight;
91
+ declare const index$6_setOffset: typeof setOffset;
92
+ declare const index$6_setRect: typeof setRect;
93
+ declare const index$6_setVisibility: typeof setVisibility;
94
+ declare const index$6_setWidth: typeof setWidth;
95
+ declare const index$6_styleLayoutChanged: typeof styleLayoutChanged;
96
+ declare namespace index$6 {
97
+ export { type index$6_CSSProperties as CSSProperties, index$6_addClass as addClass, index$6_appendTo as appendTo, index$6_getButton as getButton, index$6_getCanvas as getCanvas, index$6_getCanvasTextWidth as getCanvasTextWidth, index$6_getDimension as getDimension, index$6_getHeight as getHeight, index$6_getOffset as getOffset, index$6_getPadding as getPadding, index$6_getWidth as getWidth, index$6_hasClass as hasClass, index$6_removeClass as removeClass, index$6_removeFromParent as removeFromParent, index$6_setHeight as setHeight, index$6_setOffset as setOffset, index$6_setRect as setRect, index$6_setVisibility as setVisibility, index$6_setWidth as setWidth, index$6_styleLayoutChanged as styleLayoutChanged };
98
98
  }
99
99
 
100
100
  type EnumObject = {
@@ -105,18 +105,18 @@ type EnumValue<E extends EnumObject> = E extends {
105
105
  } ? V : never;
106
106
  declare function getEnumValues<E extends EnumObject>(e: E): Array<EnumValue<E>>;
107
107
 
108
- type index$4_EnumObject = EnumObject;
109
- type index$4_EnumValue<E extends EnumObject> = EnumValue<E>;
110
- declare const index$4_getEnumValues: typeof getEnumValues;
111
- declare namespace index$4 {
112
- export { type index$4_EnumObject as EnumObject, type index$4_EnumValue as EnumValue, index$4_getEnumValues as getEnumValues };
108
+ type index$5_EnumObject = EnumObject;
109
+ type index$5_EnumValue<E extends EnumObject> = EnumValue<E>;
110
+ declare const index$5_getEnumValues: typeof getEnumValues;
111
+ declare namespace index$5 {
112
+ export { type index$5_EnumObject as EnumObject, type index$5_EnumValue as EnumValue, index$5_getEnumValues as getEnumValues };
113
113
  }
114
114
 
115
115
  declare function getMapKeys<K, V>(map: Map<K, V>): K[];
116
116
 
117
- declare const index$3_getMapKeys: typeof getMapKeys;
118
- declare namespace index$3 {
119
- export { index$3_getMapKeys as getMapKeys };
117
+ declare const index$4_getMapKeys: typeof getMapKeys;
118
+ declare namespace index$4 {
119
+ export { index$4_getMapKeys as getMapKeys };
120
120
  }
121
121
 
122
122
  declare function isInteger(n: unknown): n is number;
@@ -140,25 +140,25 @@ declare function calcNormal(x1: number, y1: number, x2: number, y2: number): {
140
140
  };
141
141
  declare function sum(arr: number[]): number;
142
142
 
143
- declare const index$2_calcNormal: typeof calcNormal;
144
- declare const index$2_clamp: typeof clamp;
145
- declare const index$2_interpolateCoord: typeof interpolateCoord;
146
- declare const index$2_interpolateY: typeof interpolateY;
147
- declare const index$2_isInteger: typeof isInteger;
148
- declare const index$2_linearToDecibels: typeof linearToDecibels;
149
- declare const index$2_mod: typeof mod;
150
- declare const index$2_romanize: typeof romanize;
151
- declare const index$2_sum: typeof sum;
152
- declare const index$2_toOrdinalNumber: typeof toOrdinalNumber;
153
- declare namespace index$2 {
154
- export { index$2_calcNormal as calcNormal, index$2_clamp as clamp, index$2_interpolateCoord as interpolateCoord, index$2_interpolateY as interpolateY, index$2_isInteger as isInteger, index$2_linearToDecibels as linearToDecibels, index$2_mod as mod, index$2_romanize as romanize, index$2_sum as sum, index$2_toOrdinalNumber as toOrdinalNumber };
143
+ declare const index$3_calcNormal: typeof calcNormal;
144
+ declare const index$3_clamp: typeof clamp;
145
+ declare const index$3_interpolateCoord: typeof interpolateCoord;
146
+ declare const index$3_interpolateY: typeof interpolateY;
147
+ declare const index$3_isInteger: typeof isInteger;
148
+ declare const index$3_linearToDecibels: typeof linearToDecibels;
149
+ declare const index$3_mod: typeof mod;
150
+ declare const index$3_romanize: typeof romanize;
151
+ declare const index$3_sum: typeof sum;
152
+ declare const index$3_toOrdinalNumber: typeof toOrdinalNumber;
153
+ declare namespace index$3 {
154
+ export { index$3_calcNormal as calcNormal, index$3_clamp as clamp, index$3_interpolateCoord as interpolateCoord, index$3_interpolateY as interpolateY, index$3_isInteger as isInteger, index$3_linearToDecibels as linearToDecibels, index$3_mod as mod, index$3_romanize as romanize, index$3_sum as sum, index$3_toOrdinalNumber as toOrdinalNumber };
155
155
  }
156
156
 
157
157
  declare function isObject(value: unknown): value is Record<string, unknown>;
158
158
 
159
- declare const index$1_isObject: typeof isObject;
160
- declare namespace index$1 {
161
- export { index$1_isObject as isObject };
159
+ declare const index$2_isObject: typeof isObject;
160
+ declare namespace index$2 {
161
+ export { index$2_isObject as isObject };
162
162
  }
163
163
 
164
164
  /**
@@ -207,25 +207,26 @@ declare function removeAt(str: string, pos: number, removeCount: number): string
207
207
  */
208
208
  declare function makeSentenceFromPascal(PascalString: string): string;
209
209
 
210
- declare const index_chunkString: typeof chunkString;
211
- declare const index_insertAt: typeof insertAt;
212
- declare const index_makeSentenceFromPascal: typeof makeSentenceFromPascal;
213
- declare const index_removeAt: typeof removeAt;
214
- declare const index_repeatString: typeof repeatString;
215
- declare const index_replaceAt: typeof replaceAt;
216
- declare const index_toCharArray: typeof toCharArray;
217
- declare namespace index {
218
- export { index_chunkString as chunkString, index_insertAt as insertAt, index_makeSentenceFromPascal as makeSentenceFromPascal, index_removeAt as removeAt, index_repeatString as repeatString, index_replaceAt as replaceAt, index_toCharArray as toCharArray };
210
+ declare const index$1_chunkString: typeof chunkString;
211
+ declare const index$1_insertAt: typeof insertAt;
212
+ declare const index$1_makeSentenceFromPascal: typeof makeSentenceFromPascal;
213
+ declare const index$1_removeAt: typeof removeAt;
214
+ declare const index$1_repeatString: typeof repeatString;
215
+ declare const index$1_replaceAt: typeof replaceAt;
216
+ declare const index$1_toCharArray: typeof toCharArray;
217
+ declare namespace index$1 {
218
+ export { index$1_chunkString as chunkString, index$1_insertAt as insertAt, index$1_makeSentenceFromPascal as makeSentenceFromPascal, index$1_removeAt as removeAt, index$1_repeatString as repeatString, index$1_replaceAt as replaceAt, index$1_toCharArray as toCharArray };
219
219
  }
220
220
 
221
- declare namespace exportUtils {
222
- export { index$6 as Arr, index$5 as Dom, index$4 as Enum, index$3 as Map, index$2 as Math, index$1 as Obj, index as Str };
221
+ declare namespace index {
222
+ export { index$7 as Arr, index$6 as Dom, index$5 as Enum, index$4 as Map, index$3 as Math, index$2 as Obj, index$1 as Str };
223
223
  }
224
224
 
225
225
  declare namespace Assert {
226
226
  type ErrorConstructor = new (msg: string) => Error;
227
227
  function setErrorClass(ec?: ErrorConstructor): void;
228
228
  function assert<T>(a: T, userMsg?: string): void;
229
+ function assertEnum<E extends Record<string, string | number>>(value: unknown, enumObj: E, name?: string): asserts value is E[keyof E];
229
230
  function interrupt(userMsg?: string): never;
230
231
  function int(a: unknown, userMsg?: string): number;
231
232
  function eq<T>(a: T, b: T, userMsg?: string): T;
@@ -344,4 +345,4 @@ declare class SmallIntCache<V> {
344
345
  clear(): void;
345
346
  }
346
347
 
347
- export { Assert, Cookies, Device, LRUCache, SmallIntCache, Stack, exportUtils as Utils, Vec2 };
348
+ export { Assert, Cookies, Device, LRUCache, SmallIntCache, Stack, index as Utils, Vec2 };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /* TsUtilsLib v1.0.1 | (c) 2023 PahkaSoft | Licensed under the MIT License */
1
+ /* TsUtilsLib v1.2.0 | (c) 2023 PahkaSoft | Licensed under the MIT License */
2
2
  "use strict";
3
3
  var __defProp = Object.defineProperty;
4
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -29,26 +29,26 @@ __export(index_exports, {
29
29
  LRUCache: () => LRUCache,
30
30
  SmallIntCache: () => SmallIntCache,
31
31
  Stack: () => Stack,
32
- Utils: () => export_utils_exports,
32
+ Utils: () => utils_exports,
33
33
  Vec2: () => Vec2
34
34
  });
35
35
  module.exports = __toCommonJS(index_exports);
36
36
 
37
- // src/export-utils.ts
38
- var export_utils_exports = {};
39
- __export(export_utils_exports, {
40
- Arr: () => array_exports,
37
+ // src/utils/index.ts
38
+ var utils_exports = {};
39
+ __export(utils_exports, {
40
+ Arr: () => arr_exports,
41
41
  Dom: () => dom_exports,
42
42
  Enum: () => enum_exports,
43
43
  Map: () => map_exports,
44
44
  Math: () => math_exports,
45
- Obj: () => object_exports,
46
- Str: () => string_exports
45
+ Obj: () => obj_exports,
46
+ Str: () => str_exports
47
47
  });
48
48
 
49
- // src/array/index.ts
50
- var array_exports = {};
51
- __export(array_exports, {
49
+ // src/utils/arr/index.ts
50
+ var arr_exports = {};
51
+ __export(arr_exports, {
52
52
  arrayContains: () => arrayContains,
53
53
  chunckArray: () => chunckArray,
54
54
  duplicate: () => duplicate,
@@ -63,7 +63,7 @@ __export(array_exports, {
63
63
  toArray: () => toArray
64
64
  });
65
65
 
66
- // src/math/index.ts
66
+ // src/utils/math/index.ts
67
67
  var math_exports = {};
68
68
  __export(math_exports, {
69
69
  calcNormal: () => calcNormal,
@@ -181,7 +181,7 @@ function sum(arr) {
181
181
  return arr.reduce((prev, cur) => cur + prev, 0);
182
182
  }
183
183
 
184
- // src/array/index.ts
184
+ // src/utils/arr/index.ts
185
185
  function isArray(a) {
186
186
  return !!a && Object.prototype.toString.call(a) === "[object Array]";
187
187
  }
@@ -247,7 +247,7 @@ function chunckArray(arr, chunckSize) {
247
247
  return result;
248
248
  }
249
249
 
250
- // src/dom/index.ts
250
+ // src/utils/dom/index.ts
251
251
  var dom_exports = {};
252
252
  __export(dom_exports, {
253
253
  addClass: () => addClass,
@@ -271,6 +271,15 @@ __export(dom_exports, {
271
271
  styleLayoutChanged: () => styleLayoutChanged
272
272
  });
273
273
 
274
+ // src/utils/enum/index.ts
275
+ var enum_exports = {};
276
+ __export(enum_exports, {
277
+ getEnumValues: () => getEnumValues
278
+ });
279
+ function getEnumValues(e) {
280
+ return Object.keys(e).filter((key) => Number.isNaN(Number(key))).map((key) => e[key]);
281
+ }
282
+
274
283
  // src/modules/assert.ts
275
284
  var Assert;
276
285
  ((Assert2) => {
@@ -294,6 +303,12 @@ var Assert;
294
303
  }
295
304
  }
296
305
  Assert2.assert = assert;
306
+ function assertEnum(value, enumObj, name = "value") {
307
+ if (!getEnumValues(enumObj).some((v) => v === value)) {
308
+ throw new TypeError(`Invalid ${name} enum value: ${value}`);
309
+ }
310
+ }
311
+ Assert2.assertEnum = assertEnum;
297
312
  function interrupt(userMsg) {
298
313
  throwError(userMsg ?? "Interrupted!");
299
314
  }
@@ -516,7 +531,7 @@ var Device;
516
531
  Device2.toPx = toPx2;
517
532
  })(Device || (Device = {}));
518
533
 
519
- // src/dom/index.ts
534
+ // src/utils/dom/index.ts
520
535
  function toPx(value) {
521
536
  return value === void 0 ? void 0 : Device.toPx(value);
522
537
  }
@@ -684,16 +699,7 @@ function getCanvasTextWidth(text, font) {
684
699
  return ctx.measureText(text).width;
685
700
  }
686
701
 
687
- // src/enum/index.ts
688
- var enum_exports = {};
689
- __export(enum_exports, {
690
- getEnumValues: () => getEnumValues
691
- });
692
- function getEnumValues(e) {
693
- return Object.keys(e).filter((key) => Number.isNaN(Number(key))).map((key) => e[key]);
694
- }
695
-
696
- // src/map/index.ts
702
+ // src/utils/map/index.ts
697
703
  var map_exports = {};
698
704
  __export(map_exports, {
699
705
  getMapKeys: () => getMapKeys
@@ -704,18 +710,18 @@ function getMapKeys(map) {
704
710
  return keys;
705
711
  }
706
712
 
707
- // src/object/index.ts
708
- var object_exports = {};
709
- __export(object_exports, {
713
+ // src/utils/obj/index.ts
714
+ var obj_exports = {};
715
+ __export(obj_exports, {
710
716
  isObject: () => isObject
711
717
  });
712
718
  function isObject(value) {
713
719
  return typeof value === "object" && value !== null && !isArray(value);
714
720
  }
715
721
 
716
- // src/string/index.ts
717
- var string_exports = {};
718
- __export(string_exports, {
722
+ // src/utils/str/index.ts
723
+ var str_exports = {};
724
+ __export(str_exports, {
719
725
  chunkString: () => chunkString,
720
726
  insertAt: () => insertAt,
721
727
  makeSentenceFromPascal: () => makeSentenceFromPascal,