@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.cjs
CHANGED
|
@@ -404,7 +404,10 @@ ${opts.message || this.desc}`;
|
|
|
404
404
|
this.version = version;
|
|
405
405
|
this.connection = new Promise((resolve, reject) => {
|
|
406
406
|
const req = indexedDB.open(this.database, this.version);
|
|
407
|
-
this.tables = tables.map((t) =>
|
|
407
|
+
this.tables = tables.map((t) => {
|
|
408
|
+
t = typeof t == "object" ? t : { name: t };
|
|
409
|
+
return { ...t, name: t.name.toString() };
|
|
410
|
+
});
|
|
408
411
|
const tableNames = new ASet(this.tables.map((t) => t.name));
|
|
409
412
|
req.onerror = () => reject(req.error);
|
|
410
413
|
req.onsuccess = () => {
|
|
@@ -658,8 +661,9 @@ ${opts.message || this.desc}`;
|
|
|
658
661
|
const SYMBOL_LIST = "~`!@#$%^&*()_-+={[}]|\\:;\"'<,>.?/";
|
|
659
662
|
const CHAR_LIST = LETTER_LIST + LETTER_LIST.toLowerCase() + NUMBER_LIST + SYMBOL_LIST;
|
|
660
663
|
function camelCase(str) {
|
|
661
|
-
|
|
662
|
-
|
|
664
|
+
if (!str) return "";
|
|
665
|
+
const pascal = pascalCase(str);
|
|
666
|
+
return pascal.charAt(0).toLowerCase() + pascal.slice(1);
|
|
663
667
|
}
|
|
664
668
|
function formatBytes(bytes, decimals = 2) {
|
|
665
669
|
if (bytes === 0) return "0 Bytes";
|
|
@@ -678,16 +682,15 @@ ${opts.message || this.desc}`;
|
|
|
678
682
|
}
|
|
679
683
|
function kebabCase(str) {
|
|
680
684
|
if (!str) return "";
|
|
681
|
-
return str
|
|
685
|
+
return wordSegments(str).map((w) => w.toLowerCase()).join("-");
|
|
682
686
|
}
|
|
683
687
|
function pad(text, length, char = " ", start = true) {
|
|
684
688
|
if (start) return text.toString().padStart(length, char);
|
|
685
689
|
return text.toString().padEnd(length, char);
|
|
686
690
|
}
|
|
687
691
|
function pascalCase(str) {
|
|
688
|
-
var _a;
|
|
689
692
|
if (!str) return "";
|
|
690
|
-
return (
|
|
693
|
+
return wordSegments(str).map((w) => w.charAt(0).toUpperCase() + w.slice(1).toLowerCase()).join("");
|
|
691
694
|
}
|
|
692
695
|
function randomHex(length) {
|
|
693
696
|
return Array(length).fill(null).map(() => Math.round(Math.random() * 15).toString(16)).join("");
|
|
@@ -717,7 +720,7 @@ ${opts.message || this.desc}`;
|
|
|
717
720
|
}
|
|
718
721
|
function snakeCase(str) {
|
|
719
722
|
if (!str) return "";
|
|
720
|
-
return str
|
|
723
|
+
return wordSegments(str).map((w) => w.toLowerCase()).join("_");
|
|
721
724
|
}
|
|
722
725
|
function strSplice(str, start, deleteCount, insert = "") {
|
|
723
726
|
const before = str.slice(0, start);
|
|
@@ -807,6 +810,10 @@ ${opts.message || this.desc}`;
|
|
|
807
810
|
function bit_rol(d, _) {
|
|
808
811
|
return d << _ | d >>> 32 - _;
|
|
809
812
|
}
|
|
813
|
+
function wordSegments(str) {
|
|
814
|
+
if (!str) return [];
|
|
815
|
+
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);
|
|
816
|
+
}
|
|
810
817
|
function validateEmail(email) {
|
|
811
818
|
return /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/.test(email);
|
|
812
819
|
}
|
|
@@ -2118,6 +2125,7 @@ ${opts.message || this.desc}`;
|
|
|
2118
2125
|
exports2.toCsv = toCsv;
|
|
2119
2126
|
exports2.uploadWithProgress = uploadWithProgress;
|
|
2120
2127
|
exports2.validateEmail = validateEmail;
|
|
2128
|
+
exports2.wordSegments = wordSegments;
|
|
2121
2129
|
Object.defineProperty(exports2, Symbol.toStringTag, { value: "Module" });
|
|
2122
2130
|
});
|
|
2123
2131
|
//# sourceMappingURL=index.cjs.map
|