@tspro/ts-utils-lib 2.1.0 → 2.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/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
3
  /*!
4
- * TsUtilsLib v2.1.0 (cjs)
5
- * (c) 20232025 PahkaSoft
4
+ * TsUtilsLib v2.2.0 (cjs)
5
+ * (c) 2023-2025 PahkaSoft
6
6
  * Licensed under the MIT License
7
7
  */
8
8
  var __defProp = Object.defineProperty;
@@ -70,6 +70,11 @@ __export(assert_exports, {
70
70
  isNumber: () => isNumber2,
71
71
  isNumberBetween: () => isNumberBetween2,
72
72
  isNumberBetweenExclusive: () => isNumberBetweenExclusive2,
73
+ isNumberEq: () => isNumberEq2,
74
+ isNumberGt: () => isNumberGt2,
75
+ isNumberGte: () => isNumberGte2,
76
+ isNumberLt: () => isNumberLt2,
77
+ isNumberLte: () => isNumberLte2,
73
78
  isNumberOrUndefined: () => isNumberOrUndefined2,
74
79
  isNumericString: () => isNumericString2,
75
80
  isObject: () => isObject2,
@@ -81,6 +86,7 @@ __export(assert_exports, {
81
86
  isPosZero: () => isPosZero2,
82
87
  isPowerOfTwo: () => isPowerOfTwo2,
83
88
  isSafeInteger: () => isSafeInteger2,
89
+ isSafeNumber: () => isSafeNumber2,
84
90
  isStrictEqual: () => isStrictEqual2,
85
91
  isString: () => isString2,
86
92
  isStringOrUndefined: () => isStringOrUndefined2,
@@ -106,6 +112,9 @@ __export(str_exports, {
106
112
  removeAt: () => removeAt,
107
113
  repeatString: () => repeatString,
108
114
  replaceAt: () => replaceAt,
115
+ splitByCaps: () => splitByCaps,
116
+ splitByChars: () => splitByChars,
117
+ splitByStrings: () => splitByStrings,
109
118
  stringify: () => stringify,
110
119
  toCharArray: () => toCharArray
111
120
  });
@@ -174,6 +183,11 @@ __export(guard_exports, {
174
183
  isNumber: () => isNumber,
175
184
  isNumberBetween: () => isNumberBetween,
176
185
  isNumberBetweenExclusive: () => isNumberBetweenExclusive,
186
+ isNumberEq: () => isNumberEq,
187
+ isNumberGt: () => isNumberGt,
188
+ isNumberGte: () => isNumberGte,
189
+ isNumberLt: () => isNumberLt,
190
+ isNumberLte: () => isNumberLte,
177
191
  isNumberOrUndefined: () => isNumberOrUndefined,
178
192
  isNumericString: () => isNumericString,
179
193
  isObject: () => isObject,
@@ -185,6 +199,7 @@ __export(guard_exports, {
185
199
  isPosZero: () => isPosZero,
186
200
  isPowerOfTwo: () => isPowerOfTwo,
187
201
  isSafeInteger: () => isSafeInteger,
202
+ isSafeNumber: () => isSafeNumber,
188
203
  isStrictEqual: () => isStrictEqual,
189
204
  isString: () => isString,
190
205
  isStringOrUndefined: () => isStringOrUndefined,
@@ -340,9 +355,33 @@ function isBigInt(val) {
340
355
  function isNumber(val) {
341
356
  return typeof val === "number";
342
357
  }
358
+ function isSafeNumber(val) {
359
+ return isNumber(val) && Number.isSafeInteger(val);
360
+ }
343
361
  function isNumberOrUndefined(val) {
344
362
  return typeof val === "number" || val === void 0;
345
363
  }
364
+ function isNumberEq(val, ref) {
365
+ return isNumber(val) && val === ref;
366
+ }
367
+ function isNumberGt(val, ref) {
368
+ return isNumber(val) && isNumber(ref) && val > ref;
369
+ }
370
+ function isNumberGte(val, ref) {
371
+ return isNumber(val) && isNumber(ref) && val >= ref;
372
+ }
373
+ function isNumberLt(val, ref) {
374
+ return isNumber(val) && isNumber(ref) && val < ref;
375
+ }
376
+ function isNumberLte(val, ref) {
377
+ return isNumber(val) && isNumber(ref) && val <= ref;
378
+ }
379
+ function isNumberBetween(val, min, max) {
380
+ return isNumber(val) && isNumber(min) && isNumber(max) && val >= min && val <= max;
381
+ }
382
+ function isNumberBetweenExclusive(val, min, max) {
383
+ return isNumber(val) && isNumber(min) && isNumber(max) && val > min && val < max;
384
+ }
346
385
  function isFinite2(val) {
347
386
  return typeof val === "number" && Number.isFinite(val);
348
387
  }
@@ -379,12 +418,6 @@ function isIntegerBetween(val, min, max) {
379
418
  function isIntegerBetweenExclusive(val, min, max) {
380
419
  return isInteger(val) && isNumber(min) && isNumber(max) && val > min && val < max;
381
420
  }
382
- function isNumberBetween(val, min, max) {
383
- return isNumber(val) && isNumber(min) && isNumber(max) && val >= min && val <= max;
384
- }
385
- function isNumberBetweenExclusive(val, min, max) {
386
- return isNumber(val) && isNumber(min) && isNumber(max) && val > min && val < max;
387
- }
388
421
  function isNaNValue(val) {
389
422
  return typeof val === "number" && Number.isNaN(val);
390
423
  }
@@ -654,6 +687,18 @@ function stringify(value, maxDepth = 5, seen = /* @__PURE__ */ new WeakSet()) {
654
687
  }
655
688
  return String(value);
656
689
  }
690
+ function splitByCaps(str2) {
691
+ return str2.split(/(?=[A-Z])/).filter((x) => !!x);
692
+ }
693
+ function splitByStrings(str2, ...splitters) {
694
+ if (splitters.length === 0) return [str2];
695
+ const escaped = splitters.map((s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"));
696
+ const regex = new RegExp(escaped.join("|"), "g");
697
+ return str2.split(regex);
698
+ }
699
+ function splitByChars(str2, splitters) {
700
+ return splitByStrings(str2, ...splitters.split(""));
701
+ }
657
702
 
658
703
  // src/assert/index.ts
659
704
  var fmt = stringify;
@@ -873,11 +918,51 @@ function isNumber2(val, msg) {
873
918
  _fail(`Expected ${fmt(val)} to be number`, msg);
874
919
  return val;
875
920
  }
921
+ function isSafeNumber2(val, msg) {
922
+ if (!guard_exports.isSafeNumber(val))
923
+ _fail(`Expected ${fmt(val)} to be safe number`, msg);
924
+ return val;
925
+ }
876
926
  function isNumberOrUndefined2(val, msg) {
877
927
  if (!guard_exports.isNumberOrUndefined(val))
878
928
  _fail(`Expected ${fmt(val)} to be number or undefined`, msg);
879
929
  return val;
880
930
  }
931
+ function isNumberEq2(val, ref, msg) {
932
+ if (!guard_exports.isNumberEq(val, ref))
933
+ _fail(`Expected ${fmt(val)} to be number equal to ${fmt(ref)}`, msg);
934
+ return val;
935
+ }
936
+ function isNumberGt2(val, ref, msg) {
937
+ if (!guard_exports.isNumberGt(val, ref))
938
+ _fail(`Expected ${fmt(val)} to be number > ${fmt(ref)}`, msg);
939
+ return val;
940
+ }
941
+ function isNumberGte2(val, ref, msg) {
942
+ if (!guard_exports.isNumberGte(val, ref))
943
+ _fail(`Expected ${fmt(val)} to be number >= ${fmt(ref)}`, msg);
944
+ return val;
945
+ }
946
+ function isNumberLt2(val, ref, msg) {
947
+ if (!guard_exports.isNumberLt(val, ref))
948
+ _fail(`Expected ${fmt(val)} to be number < ${fmt(ref)}`, msg);
949
+ return val;
950
+ }
951
+ function isNumberLte2(val, ref, msg) {
952
+ if (!guard_exports.isNumberLte(val, ref))
953
+ _fail(`Expected ${fmt(val)} to be number <= ${fmt(ref)}`, msg);
954
+ return val;
955
+ }
956
+ function isNumberBetween2(val, min, max, msg) {
957
+ if (!guard_exports.isNumberBetween(val, min, max))
958
+ _fail(`Expected number ${fmt(min)} <= ${fmt(val)} <= ${fmt(max)}`, msg);
959
+ return val;
960
+ }
961
+ function isNumberBetweenExclusive2(val, min, max, msg) {
962
+ if (!guard_exports.isNumberBetweenExclusive(val, min, max))
963
+ _fail(`Expected number ${fmt(min)} < ${fmt(val)} < ${fmt(max)}`, msg);
964
+ return val;
965
+ }
881
966
  function isFinite3(val, msg) {
882
967
  if (!guard_exports.isFinite(val))
883
968
  _fail(`Expected ${fmt(val)} to be finite`, msg);
@@ -938,16 +1023,6 @@ function isIntegerBetweenExclusive2(val, min, max, msg) {
938
1023
  _fail(`Expected integer ${fmt(min)} < ${fmt(val)} < ${fmt(max)}`, msg);
939
1024
  return val;
940
1025
  }
941
- function isNumberBetween2(val, min, max, msg) {
942
- if (!guard_exports.isNumberBetween(val, min, max))
943
- _fail(`Expected number ${fmt(min)} <= ${fmt(val)} <= ${fmt(max)}`, msg);
944
- return val;
945
- }
946
- function isNumberBetweenExclusive2(val, min, max, msg) {
947
- if (!guard_exports.isNumberBetweenExclusive(val, min, max))
948
- _fail(`Expected number ${fmt(min)} < ${fmt(val)} < ${fmt(max)}`, msg);
949
- return val;
950
- }
951
1026
  function isNaNValue2(val, msg) {
952
1027
  if (!guard_exports.isNaNValue(val))
953
1028
  _fail(`Expected ${fmt(val)} to be NaN`, msg);
@@ -4269,7 +4344,7 @@ var LinkedList = class _LinkedList extends BaseContainer {
4269
4344
 
4270
4345
  // src/index.ts
4271
4346
  function getLibInfo() {
4272
- return "TsUtilsLib v2.1.0 (cjs)";
4347
+ return "TsUtilsLib v2.2.0 (cjs)";
4273
4348
  }
4274
4349
 
4275
4350
  exports.AnchoredRect = AnchoredRect;
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * TsUtilsLib v2.1.0 (esm)
3
- * (c) 20232025 PahkaSoft
2
+ * TsUtilsLib v2.2.0 (esm)
3
+ * (c) 2023-2025 PahkaSoft
4
4
  * Licensed under the MIT License
5
5
  */
6
6
  var __defProp = Object.defineProperty;
@@ -68,6 +68,11 @@ __export(assert_exports, {
68
68
  isNumber: () => isNumber2,
69
69
  isNumberBetween: () => isNumberBetween2,
70
70
  isNumberBetweenExclusive: () => isNumberBetweenExclusive2,
71
+ isNumberEq: () => isNumberEq2,
72
+ isNumberGt: () => isNumberGt2,
73
+ isNumberGte: () => isNumberGte2,
74
+ isNumberLt: () => isNumberLt2,
75
+ isNumberLte: () => isNumberLte2,
71
76
  isNumberOrUndefined: () => isNumberOrUndefined2,
72
77
  isNumericString: () => isNumericString2,
73
78
  isObject: () => isObject2,
@@ -79,6 +84,7 @@ __export(assert_exports, {
79
84
  isPosZero: () => isPosZero2,
80
85
  isPowerOfTwo: () => isPowerOfTwo2,
81
86
  isSafeInteger: () => isSafeInteger2,
87
+ isSafeNumber: () => isSafeNumber2,
82
88
  isStrictEqual: () => isStrictEqual2,
83
89
  isString: () => isString2,
84
90
  isStringOrUndefined: () => isStringOrUndefined2,
@@ -104,6 +110,9 @@ __export(str_exports, {
104
110
  removeAt: () => removeAt,
105
111
  repeatString: () => repeatString,
106
112
  replaceAt: () => replaceAt,
113
+ splitByCaps: () => splitByCaps,
114
+ splitByChars: () => splitByChars,
115
+ splitByStrings: () => splitByStrings,
107
116
  stringify: () => stringify,
108
117
  toCharArray: () => toCharArray
109
118
  });
@@ -172,6 +181,11 @@ __export(guard_exports, {
172
181
  isNumber: () => isNumber,
173
182
  isNumberBetween: () => isNumberBetween,
174
183
  isNumberBetweenExclusive: () => isNumberBetweenExclusive,
184
+ isNumberEq: () => isNumberEq,
185
+ isNumberGt: () => isNumberGt,
186
+ isNumberGte: () => isNumberGte,
187
+ isNumberLt: () => isNumberLt,
188
+ isNumberLte: () => isNumberLte,
175
189
  isNumberOrUndefined: () => isNumberOrUndefined,
176
190
  isNumericString: () => isNumericString,
177
191
  isObject: () => isObject,
@@ -183,6 +197,7 @@ __export(guard_exports, {
183
197
  isPosZero: () => isPosZero,
184
198
  isPowerOfTwo: () => isPowerOfTwo,
185
199
  isSafeInteger: () => isSafeInteger,
200
+ isSafeNumber: () => isSafeNumber,
186
201
  isStrictEqual: () => isStrictEqual,
187
202
  isString: () => isString,
188
203
  isStringOrUndefined: () => isStringOrUndefined,
@@ -338,9 +353,33 @@ function isBigInt(val) {
338
353
  function isNumber(val) {
339
354
  return typeof val === "number";
340
355
  }
356
+ function isSafeNumber(val) {
357
+ return isNumber(val) && Number.isSafeInteger(val);
358
+ }
341
359
  function isNumberOrUndefined(val) {
342
360
  return typeof val === "number" || val === void 0;
343
361
  }
362
+ function isNumberEq(val, ref) {
363
+ return isNumber(val) && val === ref;
364
+ }
365
+ function isNumberGt(val, ref) {
366
+ return isNumber(val) && isNumber(ref) && val > ref;
367
+ }
368
+ function isNumberGte(val, ref) {
369
+ return isNumber(val) && isNumber(ref) && val >= ref;
370
+ }
371
+ function isNumberLt(val, ref) {
372
+ return isNumber(val) && isNumber(ref) && val < ref;
373
+ }
374
+ function isNumberLte(val, ref) {
375
+ return isNumber(val) && isNumber(ref) && val <= ref;
376
+ }
377
+ function isNumberBetween(val, min, max) {
378
+ return isNumber(val) && isNumber(min) && isNumber(max) && val >= min && val <= max;
379
+ }
380
+ function isNumberBetweenExclusive(val, min, max) {
381
+ return isNumber(val) && isNumber(min) && isNumber(max) && val > min && val < max;
382
+ }
344
383
  function isFinite2(val) {
345
384
  return typeof val === "number" && Number.isFinite(val);
346
385
  }
@@ -377,12 +416,6 @@ function isIntegerBetween(val, min, max) {
377
416
  function isIntegerBetweenExclusive(val, min, max) {
378
417
  return isInteger(val) && isNumber(min) && isNumber(max) && val > min && val < max;
379
418
  }
380
- function isNumberBetween(val, min, max) {
381
- return isNumber(val) && isNumber(min) && isNumber(max) && val >= min && val <= max;
382
- }
383
- function isNumberBetweenExclusive(val, min, max) {
384
- return isNumber(val) && isNumber(min) && isNumber(max) && val > min && val < max;
385
- }
386
419
  function isNaNValue(val) {
387
420
  return typeof val === "number" && Number.isNaN(val);
388
421
  }
@@ -652,6 +685,18 @@ function stringify(value, maxDepth = 5, seen = /* @__PURE__ */ new WeakSet()) {
652
685
  }
653
686
  return String(value);
654
687
  }
688
+ function splitByCaps(str2) {
689
+ return str2.split(/(?=[A-Z])/).filter((x) => !!x);
690
+ }
691
+ function splitByStrings(str2, ...splitters) {
692
+ if (splitters.length === 0) return [str2];
693
+ const escaped = splitters.map((s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"));
694
+ const regex = new RegExp(escaped.join("|"), "g");
695
+ return str2.split(regex);
696
+ }
697
+ function splitByChars(str2, splitters) {
698
+ return splitByStrings(str2, ...splitters.split(""));
699
+ }
655
700
 
656
701
  // src/assert/index.ts
657
702
  var fmt = stringify;
@@ -871,11 +916,51 @@ function isNumber2(val, msg) {
871
916
  _fail(`Expected ${fmt(val)} to be number`, msg);
872
917
  return val;
873
918
  }
919
+ function isSafeNumber2(val, msg) {
920
+ if (!guard_exports.isSafeNumber(val))
921
+ _fail(`Expected ${fmt(val)} to be safe number`, msg);
922
+ return val;
923
+ }
874
924
  function isNumberOrUndefined2(val, msg) {
875
925
  if (!guard_exports.isNumberOrUndefined(val))
876
926
  _fail(`Expected ${fmt(val)} to be number or undefined`, msg);
877
927
  return val;
878
928
  }
929
+ function isNumberEq2(val, ref, msg) {
930
+ if (!guard_exports.isNumberEq(val, ref))
931
+ _fail(`Expected ${fmt(val)} to be number equal to ${fmt(ref)}`, msg);
932
+ return val;
933
+ }
934
+ function isNumberGt2(val, ref, msg) {
935
+ if (!guard_exports.isNumberGt(val, ref))
936
+ _fail(`Expected ${fmt(val)} to be number > ${fmt(ref)}`, msg);
937
+ return val;
938
+ }
939
+ function isNumberGte2(val, ref, msg) {
940
+ if (!guard_exports.isNumberGte(val, ref))
941
+ _fail(`Expected ${fmt(val)} to be number >= ${fmt(ref)}`, msg);
942
+ return val;
943
+ }
944
+ function isNumberLt2(val, ref, msg) {
945
+ if (!guard_exports.isNumberLt(val, ref))
946
+ _fail(`Expected ${fmt(val)} to be number < ${fmt(ref)}`, msg);
947
+ return val;
948
+ }
949
+ function isNumberLte2(val, ref, msg) {
950
+ if (!guard_exports.isNumberLte(val, ref))
951
+ _fail(`Expected ${fmt(val)} to be number <= ${fmt(ref)}`, msg);
952
+ return val;
953
+ }
954
+ function isNumberBetween2(val, min, max, msg) {
955
+ if (!guard_exports.isNumberBetween(val, min, max))
956
+ _fail(`Expected number ${fmt(min)} <= ${fmt(val)} <= ${fmt(max)}`, msg);
957
+ return val;
958
+ }
959
+ function isNumberBetweenExclusive2(val, min, max, msg) {
960
+ if (!guard_exports.isNumberBetweenExclusive(val, min, max))
961
+ _fail(`Expected number ${fmt(min)} < ${fmt(val)} < ${fmt(max)}`, msg);
962
+ return val;
963
+ }
879
964
  function isFinite3(val, msg) {
880
965
  if (!guard_exports.isFinite(val))
881
966
  _fail(`Expected ${fmt(val)} to be finite`, msg);
@@ -936,16 +1021,6 @@ function isIntegerBetweenExclusive2(val, min, max, msg) {
936
1021
  _fail(`Expected integer ${fmt(min)} < ${fmt(val)} < ${fmt(max)}`, msg);
937
1022
  return val;
938
1023
  }
939
- function isNumberBetween2(val, min, max, msg) {
940
- if (!guard_exports.isNumberBetween(val, min, max))
941
- _fail(`Expected number ${fmt(min)} <= ${fmt(val)} <= ${fmt(max)}`, msg);
942
- return val;
943
- }
944
- function isNumberBetweenExclusive2(val, min, max, msg) {
945
- if (!guard_exports.isNumberBetweenExclusive(val, min, max))
946
- _fail(`Expected number ${fmt(min)} < ${fmt(val)} < ${fmt(max)}`, msg);
947
- return val;
948
- }
949
1024
  function isNaNValue2(val, msg) {
950
1025
  if (!guard_exports.isNaNValue(val))
951
1026
  _fail(`Expected ${fmt(val)} to be NaN`, msg);
@@ -4267,7 +4342,7 @@ var LinkedList = class _LinkedList extends BaseContainer {
4267
4342
 
4268
4343
  // src/index.ts
4269
4344
  function getLibInfo() {
4270
- return "TsUtilsLib v2.1.0 (esm)";
4345
+ return "TsUtilsLib v2.2.0 (esm)";
4271
4346
  }
4272
4347
 
4273
4348
  export { AnchoredRect, assert_exports as Assert, BaseContainer, BiMap, cookies_exports as Cookies, DefaultArray, DefaultEqualityFn, device_exports as Device, guard_exports as Guard, IndexArray, LRUCache, LinkedList, MultiContainer, Rect, SignedIndexArray, Stack, TriMap, UniMap, utils_exports as Utils, ValueSet, Vec, asMulti, getLibInfo };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tspro/ts-utils-lib",
3
- "version": "2.1.0",
3
+ "version": "2.2.0",
4
4
  "author": "PahkaSoft",
5
5
  "license": "MIT",
6
6
  "private": false,