@ztimson/utils 0.22.0 → 0.22.2
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.cjs +9 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +9 -10
- package/dist/index.mjs.map +1 -1
- package/dist/objects.d.ts +0 -1
- package/dist/path-events.d.ts +1 -1
- package/dist/string.d.ts +2 -0
- package/dist/types.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -13,7 +13,11 @@ function clean(obj, undefinedOnly = false) {
|
|
|
13
13
|
return obj;
|
|
14
14
|
}
|
|
15
15
|
function deepCopy(value) {
|
|
16
|
-
|
|
16
|
+
try {
|
|
17
|
+
return structuredClone(value);
|
|
18
|
+
} catch {
|
|
19
|
+
return JSON.parse(JSONSanitize(value));
|
|
20
|
+
}
|
|
17
21
|
}
|
|
18
22
|
function deepMerge(target, ...sources) {
|
|
19
23
|
sources.forEach((s) => {
|
|
@@ -102,12 +106,7 @@ function JSONAttemptParse(json) {
|
|
|
102
106
|
}
|
|
103
107
|
}
|
|
104
108
|
function JSONSanitize(obj, space) {
|
|
105
|
-
let cache = [];
|
|
106
109
|
return JSON.stringify(obj, (key, value) => {
|
|
107
|
-
if (typeof value === "object" && value !== null) {
|
|
108
|
-
if (cache.includes(value)) return;
|
|
109
|
-
cache.push(value);
|
|
110
|
-
}
|
|
111
110
|
return value;
|
|
112
111
|
}, space);
|
|
113
112
|
}
|
|
@@ -957,7 +956,7 @@ function formatBytes(bytes, decimals = 2) {
|
|
|
957
956
|
function formatPhoneNumber(number) {
|
|
958
957
|
const parts = /(\+?1)?.*?(\d{3}).*?(\d{3}).*?(\d{4})/g.exec(number);
|
|
959
958
|
if (!parts) throw new Error(`Number cannot be parsed: ${number}`);
|
|
960
|
-
return `${parts[1]
|
|
959
|
+
return `${parts[1] ? "+1" : ""} (${parts[2]}) ${parts[3]}-${parts[4]}`.trim();
|
|
961
960
|
}
|
|
962
961
|
function insertAt(target, str, index) {
|
|
963
962
|
return `${target.slice(0, index)}${str}${target.slice(index + 1)}`;
|
|
@@ -1123,7 +1122,7 @@ class PathEvent {
|
|
|
1123
1122
|
__publicField(this, "methods");
|
|
1124
1123
|
var _a;
|
|
1125
1124
|
if (typeof Event == "object") return Object.assign(this, Event);
|
|
1126
|
-
let [p, scope, method] = Event.split(":");
|
|
1125
|
+
let [p, scope, method] = Event.replaceAll(/\/{2,}/g, "/").split(":");
|
|
1127
1126
|
if (!method) method = scope || "*";
|
|
1128
1127
|
if (p == "*" || !p && method == "*") {
|
|
1129
1128
|
p = "";
|
|
@@ -1477,7 +1476,7 @@ async function sleepWhile(fn, checkInterval = 100) {
|
|
|
1477
1476
|
function timeUntil(date) {
|
|
1478
1477
|
return (date instanceof Date ? date.getTime() : date) - (/* @__PURE__ */ new Date()).getTime();
|
|
1479
1478
|
}
|
|
1480
|
-
function
|
|
1479
|
+
function typeKeys() {
|
|
1481
1480
|
return Object.keys({});
|
|
1482
1481
|
}
|
|
1483
1482
|
export {
|
|
@@ -1556,7 +1555,7 @@ export {
|
|
|
1556
1555
|
strSplice,
|
|
1557
1556
|
timeUntil,
|
|
1558
1557
|
timestampFilename,
|
|
1559
|
-
|
|
1558
|
+
typeKeys,
|
|
1560
1559
|
uploadWithProgress,
|
|
1561
1560
|
validateEmail
|
|
1562
1561
|
};
|