@tspro/ts-utils-lib 3.1.0 → 3.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 +10 -0
- package/README.md +6 -26
- package/dist/index.d.ts +14 -7
- package/dist/index.es5.iife.js +1 -1
- package/dist/index.es5.polyfilled.iife.js +1 -1
- package/dist/index.js +53 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +53 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
/*!
|
|
4
|
-
* TsUtilsLib v3.
|
|
4
|
+
* TsUtilsLib v3.2.0 (cjs)
|
|
5
5
|
* (c) 2023-2025 PahkaSoft
|
|
6
6
|
* Licensed under the MIT License
|
|
7
7
|
*/
|
|
@@ -116,7 +116,10 @@ __export(str_exports, {
|
|
|
116
116
|
splitByChars: () => splitByChars,
|
|
117
117
|
splitByStrings: () => splitByStrings,
|
|
118
118
|
stringify: () => stringify,
|
|
119
|
-
toCharArray: () => toCharArray
|
|
119
|
+
toCharArray: () => toCharArray,
|
|
120
|
+
trim: () => trim,
|
|
121
|
+
trimEnd: () => trimEnd,
|
|
122
|
+
trimStart: () => trimStart
|
|
120
123
|
});
|
|
121
124
|
|
|
122
125
|
// src/utils/obj/index.ts
|
|
@@ -699,6 +702,42 @@ function splitByStrings(str2, ...splitters) {
|
|
|
699
702
|
function splitByChars(str2, splitters) {
|
|
700
703
|
return splitByStrings(str2, ...splitters.split(""));
|
|
701
704
|
}
|
|
705
|
+
function trimStart(str2, ...chars) {
|
|
706
|
+
if (chars.length === 0) return str2.trimStart();
|
|
707
|
+
const sorted = [...chars].sort((a, b) => b.length - a.length);
|
|
708
|
+
let changed = true;
|
|
709
|
+
while (changed) {
|
|
710
|
+
changed = false;
|
|
711
|
+
for (const c of sorted) {
|
|
712
|
+
if (str2.startsWith(c)) {
|
|
713
|
+
str2 = str2.slice(c.length);
|
|
714
|
+
changed = true;
|
|
715
|
+
break;
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
return str2;
|
|
720
|
+
}
|
|
721
|
+
function trimEnd(str2, ...chars) {
|
|
722
|
+
if (chars.length === 0) return str2.trimEnd();
|
|
723
|
+
const sorted = [...chars].sort((a, b) => b.length - a.length);
|
|
724
|
+
let changed = true;
|
|
725
|
+
while (changed) {
|
|
726
|
+
changed = false;
|
|
727
|
+
for (const c of sorted) {
|
|
728
|
+
if (str2.endsWith(c)) {
|
|
729
|
+
str2 = str2.slice(0, -c.length);
|
|
730
|
+
changed = true;
|
|
731
|
+
break;
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
return str2;
|
|
736
|
+
}
|
|
737
|
+
function trim(str2, ...chars) {
|
|
738
|
+
if (chars.length === 0) return str2.trim();
|
|
739
|
+
return trimEnd(trimStart(str2, ...chars), ...chars);
|
|
740
|
+
}
|
|
702
741
|
|
|
703
742
|
// src/assert/index.ts
|
|
704
743
|
var fmt = stringify;
|
|
@@ -4399,14 +4438,19 @@ var _CallTracker = class _CallTracker {
|
|
|
4399
4438
|
constructor() {
|
|
4400
4439
|
__publicField(this, "counts", new UniMap((a, b) => a === b));
|
|
4401
4440
|
}
|
|
4441
|
+
track(value) {
|
|
4442
|
+
const count = this.counts.getOrCreate(value, 0);
|
|
4443
|
+
this.counts.set(value, count + 1);
|
|
4444
|
+
}
|
|
4402
4445
|
getCallCountFor(value) {
|
|
4403
|
-
|
|
4404
|
-
this.counts.set(value, oldCount + 1);
|
|
4405
|
-
return oldCount;
|
|
4446
|
+
return this.counts.get(value) ?? 0;
|
|
4406
4447
|
}
|
|
4407
4448
|
hasBeenCalledWith(value) {
|
|
4408
4449
|
return this.getCallCountFor(value) > 0;
|
|
4409
4450
|
}
|
|
4451
|
+
static track(value) {
|
|
4452
|
+
this._default.track(value);
|
|
4453
|
+
}
|
|
4410
4454
|
static getCallCountFor(value) {
|
|
4411
4455
|
return this._default.getCallCountFor(value);
|
|
4412
4456
|
}
|
|
@@ -4414,13 +4458,15 @@ var _CallTracker = class _CallTracker {
|
|
|
4414
4458
|
return this._default.hasBeenCalledWith(value);
|
|
4415
4459
|
}
|
|
4416
4460
|
};
|
|
4417
|
-
//
|
|
4461
|
+
// ─────────────────────────────────────────
|
|
4462
|
+
// Static default tracker
|
|
4463
|
+
// ─────────────────────────────────────────
|
|
4418
4464
|
__publicField(_CallTracker, "_default", new _CallTracker());
|
|
4419
4465
|
var CallTracker = _CallTracker;
|
|
4420
4466
|
|
|
4421
4467
|
// src/index.ts
|
|
4422
4468
|
function getLibInfo() {
|
|
4423
|
-
return "TsUtilsLib v3.
|
|
4469
|
+
return "TsUtilsLib v3.2.0 (cjs)";
|
|
4424
4470
|
}
|
|
4425
4471
|
|
|
4426
4472
|
exports.AnchoredRect = AnchoredRect;
|