@ztimson/utils 0.25.6 → 0.25.8
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 +15 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +16 -8
- package/dist/index.mjs.map +1 -1
- package/dist/string.d.ts +5 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -400,7 +400,10 @@ class Database {
|
|
|
400
400
|
this.version = version;
|
|
401
401
|
this.connection = new Promise((resolve, reject) => {
|
|
402
402
|
const req = indexedDB.open(this.database, this.version);
|
|
403
|
-
this.tables = tables.map((t) =>
|
|
403
|
+
this.tables = tables.map((t) => {
|
|
404
|
+
t = typeof t == "object" ? t : { name: t };
|
|
405
|
+
return { ...t, name: t.name.toString() };
|
|
406
|
+
});
|
|
404
407
|
const tableNames = new ASet(this.tables.map((t) => t.name));
|
|
405
408
|
req.onerror = () => reject(req.error);
|
|
406
409
|
req.onsuccess = () => {
|
|
@@ -654,8 +657,9 @@ const NUMBER_LIST = "0123456789";
|
|
|
654
657
|
const SYMBOL_LIST = "~`!@#$%^&*()_-+={[}]|\\:;\"'<,>.?/";
|
|
655
658
|
const CHAR_LIST = LETTER_LIST + LETTER_LIST.toLowerCase() + NUMBER_LIST + SYMBOL_LIST;
|
|
656
659
|
function camelCase(str) {
|
|
657
|
-
|
|
658
|
-
|
|
660
|
+
if (!str) return "";
|
|
661
|
+
const pascal = pascalCase(str);
|
|
662
|
+
return pascal.charAt(0).toLowerCase() + pascal.slice(1);
|
|
659
663
|
}
|
|
660
664
|
function formatBytes(bytes, decimals = 2) {
|
|
661
665
|
if (bytes === 0) return "0 Bytes";
|
|
@@ -674,16 +678,15 @@ function insertAt(target, str, index) {
|
|
|
674
678
|
}
|
|
675
679
|
function kebabCase(str) {
|
|
676
680
|
if (!str) return "";
|
|
677
|
-
return str
|
|
681
|
+
return wordSegments(str).map((w) => w.toLowerCase()).join("-");
|
|
678
682
|
}
|
|
679
683
|
function pad(text, length, char = " ", start = true) {
|
|
680
684
|
if (start) return text.toString().padStart(length, char);
|
|
681
685
|
return text.toString().padEnd(length, char);
|
|
682
686
|
}
|
|
683
687
|
function pascalCase(str) {
|
|
684
|
-
var _a;
|
|
685
688
|
if (!str) return "";
|
|
686
|
-
return (
|
|
689
|
+
return wordSegments(str).map((w) => w.charAt(0).toUpperCase() + w.slice(1).toLowerCase()).join("");
|
|
687
690
|
}
|
|
688
691
|
function randomHex(length) {
|
|
689
692
|
return Array(length).fill(null).map(() => Math.round(Math.random() * 15).toString(16)).join("");
|
|
@@ -713,7 +716,7 @@ function randomStringBuilder(length, letters = false, numbers = false, symbols =
|
|
|
713
716
|
}
|
|
714
717
|
function snakeCase(str) {
|
|
715
718
|
if (!str) return "";
|
|
716
|
-
return str
|
|
719
|
+
return wordSegments(str).map((w) => w.toLowerCase()).join("_");
|
|
717
720
|
}
|
|
718
721
|
function strSplice(str, start, deleteCount, insert = "") {
|
|
719
722
|
const before = str.slice(0, start);
|
|
@@ -803,6 +806,10 @@ function safe_add(d, _) {
|
|
|
803
806
|
function bit_rol(d, _) {
|
|
804
807
|
return d << _ | d >>> 32 - _;
|
|
805
808
|
}
|
|
809
|
+
function wordSegments(str) {
|
|
810
|
+
if (!str) return [];
|
|
811
|
+
return str.replace(/([a-z])([A-Z])/g, "$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1 $2").replace(/([0-9]+)([a-zA-Z])/g, "$1 $2").replace(/([a-zA-Z])([0-9]+)/g, "$1 $2").replace(/[_\-\s]+/g, " ").trim().split(/\s+/).filter(Boolean);
|
|
812
|
+
}
|
|
806
813
|
function validateEmail(email) {
|
|
807
814
|
return /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/.test(email);
|
|
808
815
|
}
|
|
@@ -2114,6 +2121,7 @@ export {
|
|
|
2114
2121
|
timestampFilename,
|
|
2115
2122
|
toCsv,
|
|
2116
2123
|
uploadWithProgress,
|
|
2117
|
-
validateEmail
|
|
2124
|
+
validateEmail,
|
|
2125
|
+
wordSegments
|
|
2118
2126
|
};
|
|
2119
2127
|
//# sourceMappingURL=index.mjs.map
|