@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.cjs
CHANGED
|
@@ -17,7 +17,11 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
17
17
|
return obj;
|
|
18
18
|
}
|
|
19
19
|
function deepCopy(value) {
|
|
20
|
-
|
|
20
|
+
try {
|
|
21
|
+
return structuredClone(value);
|
|
22
|
+
} catch {
|
|
23
|
+
return JSON.parse(JSONSanitize(value));
|
|
24
|
+
}
|
|
21
25
|
}
|
|
22
26
|
function deepMerge(target, ...sources) {
|
|
23
27
|
sources.forEach((s) => {
|
|
@@ -106,12 +110,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
106
110
|
}
|
|
107
111
|
}
|
|
108
112
|
function JSONSanitize(obj, space) {
|
|
109
|
-
let cache = [];
|
|
110
113
|
return JSON.stringify(obj, (key, value) => {
|
|
111
|
-
if (typeof value === "object" && value !== null) {
|
|
112
|
-
if (cache.includes(value)) return;
|
|
113
|
-
cache.push(value);
|
|
114
|
-
}
|
|
115
114
|
return value;
|
|
116
115
|
}, space);
|
|
117
116
|
}
|
|
@@ -961,7 +960,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
961
960
|
function formatPhoneNumber(number) {
|
|
962
961
|
const parts = /(\+?1)?.*?(\d{3}).*?(\d{3}).*?(\d{4})/g.exec(number);
|
|
963
962
|
if (!parts) throw new Error(`Number cannot be parsed: ${number}`);
|
|
964
|
-
return `${parts[1]
|
|
963
|
+
return `${parts[1] ? "+1" : ""} (${parts[2]}) ${parts[3]}-${parts[4]}`.trim();
|
|
965
964
|
}
|
|
966
965
|
function insertAt(target, str, index) {
|
|
967
966
|
return `${target.slice(0, index)}${str}${target.slice(index + 1)}`;
|
|
@@ -1127,7 +1126,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1127
1126
|
__publicField(this, "methods");
|
|
1128
1127
|
var _a;
|
|
1129
1128
|
if (typeof Event == "object") return Object.assign(this, Event);
|
|
1130
|
-
let [p, scope, method] = Event.split(":");
|
|
1129
|
+
let [p, scope, method] = Event.replaceAll(/\/{2,}/g, "/").split(":");
|
|
1131
1130
|
if (!method) method = scope || "*";
|
|
1132
1131
|
if (p == "*" || !p && method == "*") {
|
|
1133
1132
|
p = "";
|
|
@@ -1481,7 +1480,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1481
1480
|
function timeUntil(date) {
|
|
1482
1481
|
return (date instanceof Date ? date.getTime() : date) - (/* @__PURE__ */ new Date()).getTime();
|
|
1483
1482
|
}
|
|
1484
|
-
function
|
|
1483
|
+
function typeKeys() {
|
|
1485
1484
|
return Object.keys({});
|
|
1486
1485
|
}
|
|
1487
1486
|
exports2.ASet = ASet;
|
|
@@ -1559,7 +1558,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1559
1558
|
exports2.strSplice = strSplice;
|
|
1560
1559
|
exports2.timeUntil = timeUntil;
|
|
1561
1560
|
exports2.timestampFilename = timestampFilename;
|
|
1562
|
-
exports2.
|
|
1561
|
+
exports2.typeKeys = typeKeys;
|
|
1563
1562
|
exports2.uploadWithProgress = uploadWithProgress;
|
|
1564
1563
|
exports2.validateEmail = validateEmail;
|
|
1565
1564
|
Object.defineProperty(exports2, Symbol.toStringTag, { value: "Module" });
|