@tspro/ts-utils-lib 1.8.0 → 1.10.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,16 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.10.0] - 2025-10-15
4
+ ### Added
5
+ - Map1<KEY1, VALUE>
6
+ - Map2<KEY1, KEY2, VALUE>
7
+ - Map3<KEY1, KEY2, KEY3, VALUE>
8
+
9
+ ## [1.9.0] - 2025-10-12
10
+ ### Added
11
+ - Utils.Math.avg()
12
+ - Utils.Obj.deepEqual()
13
+
3
14
  ## [1.8.0] - 2025-10-07
4
15
  ### Added
5
16
  - Utils.Math.cmp()
package/dist/index.d.mts CHANGED
@@ -217,8 +217,10 @@ declare function calcNormal(x1: number, y1: number, x2: number, y2: number): {
217
217
  ny: number;
218
218
  };
219
219
  declare function sum(arr: number[]): number;
220
+ declare function avg(...values: number[]): number;
220
221
  declare function cmp(a: number, b: number): -1 | 0 | 1;
221
222
 
223
+ declare const index$3_avg: typeof avg;
222
224
  declare const index$3_calcNormal: typeof calcNormal;
223
225
  declare const index$3_clamp: typeof clamp;
224
226
  declare const index$3_cmp: typeof cmp;
@@ -231,7 +233,7 @@ declare const index$3_romanize: typeof romanize;
231
233
  declare const index$3_sum: typeof sum;
232
234
  declare const index$3_toOrdinalNumber: typeof toOrdinalNumber;
233
235
  declare namespace index$3 {
234
- export { index$3_calcNormal as calcNormal, index$3_clamp as clamp, index$3_cmp as cmp, 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 };
236
+ export { index$3_avg as avg, index$3_calcNormal as calcNormal, index$3_clamp as clamp, index$3_cmp as cmp, 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 };
235
237
  }
236
238
 
237
239
  declare function isObject(obj: unknown): obj is Record<string, unknown>;
@@ -243,11 +245,13 @@ declare function isObject(obj: unknown): obj is Record<string, unknown>;
243
245
  * </pre>
244
246
  */
245
247
  declare function hasProperties<T extends readonly string[]>(obj: unknown, props: T | string[]): obj is Record<T[number], unknown>;
248
+ declare function deepEqual<T>(a: T, b: T): boolean;
246
249
 
250
+ declare const index$2_deepEqual: typeof deepEqual;
247
251
  declare const index$2_hasProperties: typeof hasProperties;
248
252
  declare const index$2_isObject: typeof isObject;
249
253
  declare namespace index$2 {
250
- export { index$2_hasProperties as hasProperties, index$2_isObject as isObject };
254
+ export { index$2_deepEqual as deepEqual, index$2_hasProperties as hasProperties, index$2_isObject as isObject };
251
255
  }
252
256
 
253
257
  /**
package/dist/index.d.ts CHANGED
@@ -217,8 +217,10 @@ declare function calcNormal(x1: number, y1: number, x2: number, y2: number): {
217
217
  ny: number;
218
218
  };
219
219
  declare function sum(arr: number[]): number;
220
+ declare function avg(...values: number[]): number;
220
221
  declare function cmp(a: number, b: number): -1 | 0 | 1;
221
222
 
223
+ declare const index$3_avg: typeof avg;
222
224
  declare const index$3_calcNormal: typeof calcNormal;
223
225
  declare const index$3_clamp: typeof clamp;
224
226
  declare const index$3_cmp: typeof cmp;
@@ -231,7 +233,7 @@ declare const index$3_romanize: typeof romanize;
231
233
  declare const index$3_sum: typeof sum;
232
234
  declare const index$3_toOrdinalNumber: typeof toOrdinalNumber;
233
235
  declare namespace index$3 {
234
- export { index$3_calcNormal as calcNormal, index$3_clamp as clamp, index$3_cmp as cmp, 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 };
236
+ export { index$3_avg as avg, index$3_calcNormal as calcNormal, index$3_clamp as clamp, index$3_cmp as cmp, 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 };
235
237
  }
236
238
 
237
239
  declare function isObject(obj: unknown): obj is Record<string, unknown>;
@@ -243,11 +245,13 @@ declare function isObject(obj: unknown): obj is Record<string, unknown>;
243
245
  * </pre>
244
246
  */
245
247
  declare function hasProperties<T extends readonly string[]>(obj: unknown, props: T | string[]): obj is Record<T[number], unknown>;
248
+ declare function deepEqual<T>(a: T, b: T): boolean;
246
249
 
250
+ declare const index$2_deepEqual: typeof deepEqual;
247
251
  declare const index$2_hasProperties: typeof hasProperties;
248
252
  declare const index$2_isObject: typeof isObject;
249
253
  declare namespace index$2 {
250
- export { index$2_hasProperties as hasProperties, index$2_isObject as isObject };
254
+ export { index$2_deepEqual as deepEqual, index$2_hasProperties as hasProperties, index$2_isObject as isObject };
251
255
  }
252
256
 
253
257
  /**
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /* TsUtilsLib v1.8.0 | (c) 2023 PahkaSoft | Licensed under the MIT License */
1
+ /* TsUtilsLib v1.9.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;
@@ -67,6 +67,7 @@ __export(arr_exports, {
67
67
  // src/utils/math/index.ts
68
68
  var math_exports = {};
69
69
  __export(math_exports, {
70
+ avg: () => avg,
70
71
  calcNormal: () => calcNormal,
71
72
  clamp: () => clamp,
72
73
  cmp: () => cmp,
@@ -182,6 +183,9 @@ function calcNormal(x1, y1, x2, y2) {
182
183
  function sum(arr) {
183
184
  return arr.reduce((prev, cur) => cur + prev, 0);
184
185
  }
186
+ function avg(...values) {
187
+ return sum(values) / values.length;
188
+ }
185
189
  function cmp(a, b) {
186
190
  return a < b ? -1 : a > b ? 1 : 0;
187
191
  }
@@ -875,6 +879,7 @@ function getMapKeys(map) {
875
879
  // src/utils/obj/index.ts
876
880
  var obj_exports = {};
877
881
  __export(obj_exports, {
882
+ deepEqual: () => deepEqual,
878
883
  hasProperties: () => hasProperties,
879
884
  isObject: () => isObject2
880
885
  });
@@ -884,6 +889,24 @@ function isObject2(obj) {
884
889
  function hasProperties(obj, props) {
885
890
  return isObject2(obj) && props.every((p) => p in obj);
886
891
  }
892
+ function deepEqual(a, b) {
893
+ if (a === b) return true;
894
+ if (a === null || b === null) return false;
895
+ if (typeof a !== "object" || typeof b !== "object") return false;
896
+ if (Array.isArray(a) && Array.isArray(b)) {
897
+ if (a.length !== b.length) return false;
898
+ return a.every((val, i) => deepEqual(val, b[i]));
899
+ }
900
+ if (Array.isArray(a) !== Array.isArray(b)) return false;
901
+ const keysA = Object.keys(a);
902
+ const keysB = Object.keys(b);
903
+ if (keysA.length !== keysB.length) return false;
904
+ for (const key of keysA) {
905
+ if (!Object.prototype.hasOwnProperty.call(b, key)) return false;
906
+ if (!deepEqual(a[key], b[key])) return false;
907
+ }
908
+ return true;
909
+ }
887
910
 
888
911
  // src/utils/str/index.ts
889
912
  var str_exports = {};
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- /* TsUtilsLib v1.8.0 | (c) 2023 PahkaSoft | Licensed under the MIT License */
1
+ /* TsUtilsLib v1.9.0 | (c) 2023 PahkaSoft | Licensed under the MIT License */
2
2
  var __defProp = Object.defineProperty;
3
3
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4
4
  var __export = (target, all) => {
@@ -40,6 +40,7 @@ __export(arr_exports, {
40
40
  // src/utils/math/index.ts
41
41
  var math_exports = {};
42
42
  __export(math_exports, {
43
+ avg: () => avg,
43
44
  calcNormal: () => calcNormal,
44
45
  clamp: () => clamp,
45
46
  cmp: () => cmp,
@@ -155,6 +156,9 @@ function calcNormal(x1, y1, x2, y2) {
155
156
  function sum(arr) {
156
157
  return arr.reduce((prev, cur) => cur + prev, 0);
157
158
  }
159
+ function avg(...values) {
160
+ return sum(values) / values.length;
161
+ }
158
162
  function cmp(a, b) {
159
163
  return a < b ? -1 : a > b ? 1 : 0;
160
164
  }
@@ -848,6 +852,7 @@ function getMapKeys(map) {
848
852
  // src/utils/obj/index.ts
849
853
  var obj_exports = {};
850
854
  __export(obj_exports, {
855
+ deepEqual: () => deepEqual,
851
856
  hasProperties: () => hasProperties,
852
857
  isObject: () => isObject2
853
858
  });
@@ -857,6 +862,24 @@ function isObject2(obj) {
857
862
  function hasProperties(obj, props) {
858
863
  return isObject2(obj) && props.every((p) => p in obj);
859
864
  }
865
+ function deepEqual(a, b) {
866
+ if (a === b) return true;
867
+ if (a === null || b === null) return false;
868
+ if (typeof a !== "object" || typeof b !== "object") return false;
869
+ if (Array.isArray(a) && Array.isArray(b)) {
870
+ if (a.length !== b.length) return false;
871
+ return a.every((val, i) => deepEqual(val, b[i]));
872
+ }
873
+ if (Array.isArray(a) !== Array.isArray(b)) return false;
874
+ const keysA = Object.keys(a);
875
+ const keysB = Object.keys(b);
876
+ if (keysA.length !== keysB.length) return false;
877
+ for (const key of keysA) {
878
+ if (!Object.prototype.hasOwnProperty.call(b, key)) return false;
879
+ if (!deepEqual(a[key], b[key])) return false;
880
+ }
881
+ return true;
882
+ }
860
883
 
861
884
  // src/utils/str/index.ts
862
885
  var str_exports = {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tspro/ts-utils-lib",
3
- "version": "1.8.0",
3
+ "version": "1.10.0",
4
4
  "author": "PahkaSoft",
5
5
  "license": "MIT",
6
6
  "private": false,