@tspro/ts-utils-lib 2.1.0 → 2.2.1
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 +19 -6
- package/LICENSE +1 -1
- package/README.md +12 -15
- package/dist/index.d.mts +70 -7
- package/dist/index.d.ts +70 -7
- package/dist/index.es5.iife.js +1 -1
- package/dist/index.es5.polyfilled.iife.js +1 -1
- package/dist/index.js +152 -52
- package/dist/index.mjs +152 -52
- package/package.json +4 -6
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
/*!
|
|
4
|
-
* TsUtilsLib v2.1
|
|
5
|
-
* (c) 2023
|
|
4
|
+
* TsUtilsLib v2.2.1 (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);
|
|
@@ -1070,7 +1145,9 @@ var _consent;
|
|
|
1070
1145
|
var _expires;
|
|
1071
1146
|
var str = _read(ConsentCookieName);
|
|
1072
1147
|
_consent = str === "accept" /* Accept */ || str === "decline" /* Decline */ ? str : void 0;
|
|
1073
|
-
function
|
|
1148
|
+
function _getCookieList() {
|
|
1149
|
+
if (typeof document === "undefined")
|
|
1150
|
+
return [];
|
|
1074
1151
|
let s = document.cookie;
|
|
1075
1152
|
return s.split(";").map((c) => c.trim());
|
|
1076
1153
|
}
|
|
@@ -1079,15 +1156,17 @@ function _save(name, value) {
|
|
|
1079
1156
|
if (_expires) {
|
|
1080
1157
|
cookie += "expires=" + _expires.toUTCString() + ";";
|
|
1081
1158
|
}
|
|
1082
|
-
document
|
|
1159
|
+
if (typeof document !== "undefined")
|
|
1160
|
+
document.cookie = cookie;
|
|
1083
1161
|
return value;
|
|
1084
1162
|
}
|
|
1085
1163
|
function _read(name, defaultValue) {
|
|
1086
|
-
let str2 =
|
|
1164
|
+
let str2 = _getCookieList().find((c) => c.startsWith(name + "="));
|
|
1087
1165
|
return str2 === void 0 ? defaultValue : str2.substring(name.length + 1);
|
|
1088
1166
|
}
|
|
1089
1167
|
function _erase(name) {
|
|
1090
|
-
|
|
1168
|
+
if (typeof document !== "undefined")
|
|
1169
|
+
document.cookie = name + "=;expires=Thu, 01 Jan 1970 00:00:00 UTC;";
|
|
1091
1170
|
}
|
|
1092
1171
|
function setExpireDays(days) {
|
|
1093
1172
|
_expires = /* @__PURE__ */ new Date();
|
|
@@ -1136,7 +1215,8 @@ function erase(name) {
|
|
|
1136
1215
|
_erase(name);
|
|
1137
1216
|
}
|
|
1138
1217
|
function eraseAll() {
|
|
1139
|
-
|
|
1218
|
+
if (typeof document !== "undefined")
|
|
1219
|
+
document.cookie.split(";").forEach((c) => erase(c.trim().split("=")[0]));
|
|
1140
1220
|
}
|
|
1141
1221
|
|
|
1142
1222
|
// src/web/device.ts
|
|
@@ -1154,12 +1234,16 @@ __export(device_exports, {
|
|
|
1154
1234
|
toPx: () => toPx
|
|
1155
1235
|
});
|
|
1156
1236
|
function getDPI() {
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1237
|
+
try {
|
|
1238
|
+
let el = document.createElement("div");
|
|
1239
|
+
el.style.width = "1in";
|
|
1240
|
+
document.body.appendChild(el);
|
|
1241
|
+
let dpi = el.offsetWidth;
|
|
1242
|
+
el.remove();
|
|
1243
|
+
return dpi || 96;
|
|
1244
|
+
} catch (e) {
|
|
1245
|
+
return 96;
|
|
1246
|
+
}
|
|
1163
1247
|
}
|
|
1164
1248
|
function getScrollBarWidth() {
|
|
1165
1249
|
try {
|
|
@@ -1182,18 +1266,23 @@ function getScrollBarWidth() {
|
|
|
1182
1266
|
}
|
|
1183
1267
|
}
|
|
1184
1268
|
function getSystemFontSize() {
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1269
|
+
try {
|
|
1270
|
+
let tmpDiv = document.createElement("div");
|
|
1271
|
+
tmpDiv.style.cssText = "display:inline-block; padding:0; line-height:1; position:absolute; visibility:hidden; font-size:1em";
|
|
1272
|
+
tmpDiv.appendChild(document.createTextNode("M"));
|
|
1273
|
+
document.body.appendChild(tmpDiv);
|
|
1274
|
+
let fontsize = tmpDiv.offsetHeight;
|
|
1275
|
+
document.body.removeChild(tmpDiv);
|
|
1276
|
+
return fontsize;
|
|
1277
|
+
} catch (e) {
|
|
1278
|
+
return 16;
|
|
1279
|
+
}
|
|
1192
1280
|
}
|
|
1193
1281
|
function getIsTouchDevice() {
|
|
1194
|
-
if (
|
|
1282
|
+
if (typeof window === "undefined")
|
|
1283
|
+
return false;
|
|
1284
|
+
if ("ontouchstart" in window || "DocumentTouch" in window || "createTouch" in document && "createTouchList" in document)
|
|
1195
1285
|
return true;
|
|
1196
|
-
}
|
|
1197
1286
|
var prefixes = " -webkit- -moz- -o- -ms- ".split(" ");
|
|
1198
1287
|
var mq = function(query2) {
|
|
1199
1288
|
return window.matchMedia(query2).matches;
|
|
@@ -1206,7 +1295,10 @@ function getIsMobileDevice() {
|
|
|
1206
1295
|
return /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0, 4));
|
|
1207
1296
|
}
|
|
1208
1297
|
function getHostAddress() {
|
|
1209
|
-
|
|
1298
|
+
if (typeof location === "undefined" || !location.host) {
|
|
1299
|
+
return "localhost";
|
|
1300
|
+
}
|
|
1301
|
+
return `${location.protocol}//${location.host}`;
|
|
1210
1302
|
}
|
|
1211
1303
|
var UnitRegExp = /^(mm|cm|in|inch|px|em)$/;
|
|
1212
1304
|
var ValueUnitRegExp = /^([0-9\\.]+)(.*)$/;
|
|
@@ -1366,6 +1458,9 @@ __export(dom_exports, {
|
|
|
1366
1458
|
setWidth: () => setWidth,
|
|
1367
1459
|
styleLayoutChanged: () => styleLayoutChanged
|
|
1368
1460
|
});
|
|
1461
|
+
function _getElemById(id) {
|
|
1462
|
+
return typeof document === "undefined" ? void 0 : document.getElementById(id) ?? void 0;
|
|
1463
|
+
}
|
|
1369
1464
|
function toPx2(value) {
|
|
1370
1465
|
return value === void 0 ? void 0 : device_exports.toPx(value);
|
|
1371
1466
|
}
|
|
@@ -1402,12 +1497,17 @@ function setOffset(el, left, top, unit = "px") {
|
|
|
1402
1497
|
el.style.top = top + unit;
|
|
1403
1498
|
}
|
|
1404
1499
|
function getOffset(el) {
|
|
1405
|
-
let
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
top
|
|
1409
|
-
|
|
1410
|
-
|
|
1500
|
+
let { left, top } = el.getBoundingClientRect();
|
|
1501
|
+
if (typeof window !== "undefined") {
|
|
1502
|
+
left += window.pageXOffset;
|
|
1503
|
+
top += window.pageYOffset;
|
|
1504
|
+
}
|
|
1505
|
+
if (typeof document !== "undefined") {
|
|
1506
|
+
let de = document.documentElement;
|
|
1507
|
+
left -= de.clientLeft;
|
|
1508
|
+
top -= de.clientTop;
|
|
1509
|
+
}
|
|
1510
|
+
return { left, top };
|
|
1411
1511
|
}
|
|
1412
1512
|
function getWidth(el) {
|
|
1413
1513
|
if (el instanceof Window) {
|
|
@@ -1447,11 +1547,11 @@ function setRect(el, left, top, width, height, unit = "px") {
|
|
|
1447
1547
|
el.style.height = height + unit;
|
|
1448
1548
|
}
|
|
1449
1549
|
function getButton(btn) {
|
|
1450
|
-
let el = typeof btn === "string" ?
|
|
1550
|
+
let el = typeof btn === "string" ? _getElemById(btn) : btn;
|
|
1451
1551
|
return el instanceof HTMLButtonElement ? el : void 0;
|
|
1452
1552
|
}
|
|
1453
1553
|
function getCanvas(canvas2) {
|
|
1454
|
-
let el = typeof canvas2 === "string" ?
|
|
1554
|
+
let el = typeof canvas2 === "string" ? _getElemById(canvas2) : canvas2;
|
|
1455
1555
|
return el instanceof HTMLCanvasElement ? el : void 0;
|
|
1456
1556
|
}
|
|
1457
1557
|
function getPadding(style) {
|
|
@@ -1524,11 +1624,11 @@ function styleLayoutChanged(style1, style2) {
|
|
|
1524
1624
|
}
|
|
1525
1625
|
var canvas;
|
|
1526
1626
|
function getCanvasTextWidth(text, font) {
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1627
|
+
if (!canvas && typeof document !== "undefined")
|
|
1628
|
+
canvas = document.createElement("canvas");
|
|
1629
|
+
let ctx = canvas?.getContext("2d");
|
|
1630
|
+
if (!ctx)
|
|
1530
1631
|
return 0;
|
|
1531
|
-
}
|
|
1532
1632
|
ctx.font = font;
|
|
1533
1633
|
return ctx.measureText(text).width;
|
|
1534
1634
|
}
|
|
@@ -4269,7 +4369,7 @@ var LinkedList = class _LinkedList extends BaseContainer {
|
|
|
4269
4369
|
|
|
4270
4370
|
// src/index.ts
|
|
4271
4371
|
function getLibInfo() {
|
|
4272
|
-
return "TsUtilsLib v2.1
|
|
4372
|
+
return "TsUtilsLib v2.2.1 (cjs)";
|
|
4273
4373
|
}
|
|
4274
4374
|
|
|
4275
4375
|
exports.AnchoredRect = AnchoredRect;
|