@rzl-zone/utils-js 3.12.0 → 3.12.1-beta.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/{LICENSE.md → LICENSE} +3 -3
- package/README.md +69 -96
- package/dist/.references/index.d.cts +25 -0
- package/dist/.references/index.d.ts +25 -0
- package/dist/assertIsArray-DJXkjHZs.cjs +26 -0
- package/dist/assertIsArray-DJXkjHZs.cjs.map +1 -0
- package/dist/assertIsArray-bTA3XLjq.js +20 -0
- package/dist/assertIsArray-bTA3XLjq.js.map +1 -0
- package/dist/assertIsBoolean-C8WEXVr2.cjs +1283 -0
- package/dist/assertIsBoolean-C8WEXVr2.cjs.map +1 -0
- package/dist/assertIsBoolean-DR1SaXPD.js +1073 -0
- package/dist/assertIsBoolean-DR1SaXPD.js.map +1 -0
- package/dist/assertIsString-BiHQSrB2.cjs +26 -0
- package/dist/assertIsString-BiHQSrB2.cjs.map +1 -0
- package/dist/assertIsString-CEB07_83.js +20 -0
- package/dist/assertIsString-CEB07_83.js.map +1 -0
- package/dist/assertions/index.cjs +37 -40
- package/dist/assertions/index.cjs.map +1 -0
- package/dist/assertions/index.d.cts +12 -0
- package/dist/assertions/index.d.ts +10 -824
- package/dist/assertions/index.js +30 -13
- package/dist/assertions/index.js.map +1 -0
- package/dist/conversions/index.cjs +34 -103
- package/dist/conversions/index.d.cts +12 -0
- package/dist/conversions/index.d.ts +10 -1791
- package/dist/conversions/index.js +14 -24
- package/dist/conversions-BNIh_tCH.js +380 -0
- package/dist/conversions-BNIh_tCH.js.map +1 -0
- package/dist/conversions-D_Kh0a_C.cjs +446 -0
- package/dist/conversions-D_Kh0a_C.cjs.map +1 -0
- package/dist/events/index.cjs +55 -31
- package/dist/events/index.cjs.map +1 -0
- package/dist/events/index.d.cts +176 -0
- package/dist/events/index.d.ts +164 -166
- package/dist/events/index.js +50 -12
- package/dist/events/index.js.map +1 -0
- package/dist/formatEnvPort-B3OLxQk9.cjs +171 -0
- package/dist/formatEnvPort-B3OLxQk9.cjs.map +1 -0
- package/dist/formatEnvPort-ByFVLjSV.js +159 -0
- package/dist/formatEnvPort-ByFVLjSV.js.map +1 -0
- package/dist/formatters/index.cjs +21 -61
- package/dist/formatters/index.d.cts +12 -0
- package/dist/formatters/index.d.ts +10 -2152
- package/dist/formatters/index.js +10 -18
- package/dist/formatters--1m_vpE8.js +369 -0
- package/dist/formatters--1m_vpE8.js.map +1 -0
- package/dist/formatters-Cbij0XLU.cjs +429 -0
- package/dist/formatters-Cbij0XLU.cjs.map +1 -0
- package/dist/generators/index.cjs +165 -41
- package/dist/generators/index.cjs.map +1 -0
- package/dist/generators/index.d.cts +12 -0
- package/dist/generators/index.d.ts +10 -338
- package/dist/generators/index.js +158 -14
- package/dist/generators/index.js.map +1 -0
- package/dist/index-59zbLcPr.d.ts +340 -0
- package/dist/index-B6tawc8L.d.cts +1716 -0
- package/dist/index-C267akkJ.d.ts +2158 -0
- package/dist/index-CeBC2Vvl.d.cts +2361 -0
- package/dist/index-CgRDTI6f.d.ts +822 -0
- package/dist/index-CoiUBVmr.d.ts +720 -0
- package/dist/index-D4fcasfZ.d.cts +720 -0
- package/dist/index-DDrSQKIc.d.ts +1716 -0
- package/dist/index-DsGxO31H.d.cts +765 -0
- package/dist/index-Hg1qJkjl.d.ts +765 -0
- package/dist/index-Qm3iFwd0.d.cts +2158 -0
- package/dist/index-UPp94Agr.d.ts +2361 -0
- package/dist/index-gBA_8SuF.d.cts +340 -0
- package/dist/index-jyDqzicx.d.cts +822 -0
- package/dist/isBigInt-C4krUeAw.cjs +20 -0
- package/dist/isBigInt-C4krUeAw.cjs.map +1 -0
- package/dist/isBigInt-DKe0M6hp.js +14 -0
- package/dist/isBigInt-DKe0M6hp.js.map +1 -0
- package/dist/isEmptyObject-DCipFwxJ.js +25 -0
- package/dist/isEmptyObject-DCipFwxJ.js.map +1 -0
- package/dist/isEmptyObject-ZkSwRC_D.cjs +37 -0
- package/dist/isEmptyObject-ZkSwRC_D.cjs.map +1 -0
- package/dist/isEmptyString-BXzKAC2j.js +15 -0
- package/dist/isEmptyString-BXzKAC2j.js.map +1 -0
- package/dist/isEmptyString-UiiUsSQj.cjs +21 -0
- package/dist/isEmptyString-UiiUsSQj.cjs.map +1 -0
- package/dist/isEmptyValue-BQzcjVaL.cjs +30 -0
- package/dist/isEmptyValue-BQzcjVaL.cjs.map +1 -0
- package/dist/isEmptyValue-jqOr7OHD.js +24 -0
- package/dist/isEmptyValue-jqOr7OHD.js.map +1 -0
- package/dist/isEqual-BX49cF9m.js +87 -0
- package/dist/isEqual-BX49cF9m.js.map +1 -0
- package/dist/isEqual-BvumA3RA.cjs +111 -0
- package/dist/isEqual-BvumA3RA.cjs.map +1 -0
- package/dist/isFinite-BCnaDpod.js +15 -0
- package/dist/isFinite-BCnaDpod.js.map +1 -0
- package/dist/isFinite-D24ZaE6c.cjs +21 -0
- package/dist/isFinite-D24ZaE6c.cjs.map +1 -0
- package/dist/isInteger-Caeuz0rB.cjs +20 -0
- package/dist/isInteger-Caeuz0rB.cjs.map +1 -0
- package/dist/isInteger-naMbJsxJ.js +14 -0
- package/dist/isInteger-naMbJsxJ.js.map +1 -0
- package/dist/isPlainObject-BF-2-phb.d.cts +339 -0
- package/dist/isPlainObject-DxNDL8XU.d.ts +339 -0
- package/dist/isServer-BJHVnixd.cjs +20 -0
- package/dist/isServer-BJHVnixd.cjs.map +1 -0
- package/dist/isServer-Da3o3XSs.js +14 -0
- package/dist/isServer-Da3o3XSs.js.map +1 -0
- package/dist/isTypedArray-DuNA8tK6.js +31 -0
- package/dist/isTypedArray-DuNA8tK6.js.map +1 -0
- package/dist/isTypedArray-TJptiw2b.cjs +43 -0
- package/dist/isTypedArray-TJptiw2b.cjs.map +1 -0
- package/dist/isURL-C-kSk6KJ.js +14 -0
- package/dist/isURL-C-kSk6KJ.js.map +1 -0
- package/dist/isURL-DeUPO_oR.cjs +20 -0
- package/dist/isURL-DeUPO_oR.cjs.map +1 -0
- package/dist/isValidDomain-BB9IGhJs.cjs +1845 -0
- package/dist/isValidDomain-BB9IGhJs.cjs.map +1 -0
- package/dist/isValidDomain-DoE98yhJ.js +1827 -0
- package/dist/isValidDomain-DoE98yhJ.js.map +1 -0
- package/dist/next/index.cjs +119 -214
- package/dist/next/index.cjs.map +1 -0
- package/dist/next/index.d.cts +220 -0
- package/dist/next/index.d.ts +203 -214
- package/dist/next/index.js +117 -212
- package/dist/next/index.js.map +1 -0
- package/dist/next/server/index.cjs +25 -40
- package/dist/next/server/index.cjs.map +1 -0
- package/dist/next/server/index.d.cts +39 -0
- package/dist/next/server/index.d.ts +34 -35
- package/dist/next/server/index.js +23 -38
- package/dist/next/server/index.js.map +1 -0
- package/dist/noop-B13_ii35.cjs +18 -0
- package/dist/noop-B13_ii35.cjs.map +1 -0
- package/dist/noop-ubqAIbHD.js +12 -0
- package/dist/noop-ubqAIbHD.js.map +1 -0
- package/dist/normalizeSpaces-Bg2IZW7W.js +23 -0
- package/dist/normalizeSpaces-Bg2IZW7W.js.map +1 -0
- package/dist/normalizeSpaces-ZXnR4Qzp.cjs +29 -0
- package/dist/normalizeSpaces-ZXnR4Qzp.cjs.map +1 -0
- package/dist/normalizeString-BDdkaXui.js +15 -0
- package/dist/normalizeString-BDdkaXui.js.map +1 -0
- package/dist/normalizeString-BE6ELqEb.cjs +21 -0
- package/dist/normalizeString-BE6ELqEb.cjs.map +1 -0
- package/dist/operations/index.cjs +65 -32
- package/dist/operations/index.cjs.map +1 -0
- package/dist/operations/index.d.cts +139 -0
- package/dist/operations/index.d.ts +129 -134
- package/dist/operations/index.js +61 -17
- package/dist/operations/index.js.map +1 -0
- package/dist/parsers/index.cjs +12 -19
- package/dist/parsers/index.d.cts +239 -0
- package/dist/parsers/index.d.ts +234 -235
- package/dist/parsers/index.js +10 -12
- package/dist/parsers-BSBPgvsq.js +643 -0
- package/dist/parsers-BSBPgvsq.js.map +1 -0
- package/dist/parsers-OqDeffqc.cjs +649 -0
- package/dist/parsers-OqDeffqc.cjs.map +1 -0
- package/dist/parsing-Cao8b358.js +50 -0
- package/dist/parsing-Cao8b358.js.map +1 -0
- package/dist/parsing-DOGSCH6N.cjs +56 -0
- package/dist/parsing-DOGSCH6N.cjs.map +1 -0
- package/dist/predicates/index.cjs +91 -296
- package/dist/predicates/index.d.cts +13 -0
- package/dist/predicates/index.d.ts +12 -2482
- package/dist/predicates/index.js +23 -25
- package/dist/predicates-Bj6meyXV.js +256 -0
- package/dist/predicates-Bj6meyXV.js.map +1 -0
- package/dist/predicates-D0ubqgqy.cjs +412 -0
- package/dist/predicates-D0ubqgqy.cjs.map +1 -0
- package/dist/promises/index.cjs +76 -24
- package/dist/promises/index.cjs.map +1 -0
- package/dist/promises/index.d.cts +123 -0
- package/dist/promises/index.d.ts +116 -119
- package/dist/promises/index.js +73 -13
- package/dist/promises/index.js.map +1 -0
- package/dist/punyCode-8SrbMWfM.js +179 -0
- package/dist/punyCode-8SrbMWfM.js.map +1 -0
- package/dist/punyCode-D-Qu6nj6.cjs +185 -0
- package/dist/punyCode-D-Qu6nj6.cjs.map +1 -0
- package/dist/removeSpaces-Bmc5DX4F.js +19 -0
- package/dist/removeSpaces-Bmc5DX4F.js.map +1 -0
- package/dist/removeSpaces-CWIvhZHg.cjs +25 -0
- package/dist/removeSpaces-CWIvhZHg.cjs.map +1 -0
- package/dist/rzl-utils.global.js +20 -9
- package/dist/safeJsonParse-BP38mwlj.js +184 -0
- package/dist/safeJsonParse-BP38mwlj.js.map +1 -0
- package/dist/safeJsonParse-Sms2CJf4.cjs +208 -0
- package/dist/safeJsonParse-Sms2CJf4.cjs.map +1 -0
- package/dist/safeStableStringify-CJtP89qn.cjs +106 -0
- package/dist/safeStableStringify-CJtP89qn.cjs.map +1 -0
- package/dist/safeStableStringify-CXOZ9Ub8.js +88 -0
- package/dist/safeStableStringify-CXOZ9Ub8.js.map +1 -0
- package/dist/strings/index.cjs +79 -81
- package/dist/strings/index.cjs.map +1 -0
- package/dist/strings/index.d.cts +12 -0
- package/dist/strings/index.d.ts +10 -775
- package/dist/strings/index.js +62 -14
- package/dist/strings/index.js.map +1 -0
- package/dist/tailwind/index.cjs +19 -47
- package/dist/tailwind/index.d.cts +12 -0
- package/dist/tailwind/index.d.ts +11 -712
- package/dist/tailwind/index.js +10 -12
- package/dist/tailwind-B2ssevxq.js +199 -0
- package/dist/tailwind-B2ssevxq.js.map +1 -0
- package/dist/tailwind-CHIx9uxu.cjs +247 -0
- package/dist/tailwind-CHIx9uxu.cjs.map +1 -0
- package/dist/toStringArrayUnRecursive-C4zYCja7.cjs +51 -0
- package/dist/toStringArrayUnRecursive-C4zYCja7.cjs.map +1 -0
- package/dist/toStringArrayUnRecursive-DJGtPsFb.js +39 -0
- package/dist/toStringArrayUnRecursive-DJGtPsFb.js.map +1 -0
- package/dist/urls/index.cjs +130 -57
- package/dist/urls/index.cjs.map +1 -0
- package/dist/urls/index.d.cts +737 -0
- package/dist/urls/index.d.ts +699 -708
- package/dist/urls/index.js +122 -26
- package/dist/urls/index.js.map +1 -0
- package/package.json +203 -194
- package/dist/chunk-2AFQ33D3.cjs +0 -64
- package/dist/chunk-2CYDJVGM.js +0 -246
- package/dist/chunk-2MW4JDQ2.cjs +0 -598
- package/dist/chunk-2VTDXC3N.cjs +0 -1825
- package/dist/chunk-44XX2P34.js +0 -209
- package/dist/chunk-4YLBKLGS.cjs +0 -18
- package/dist/chunk-566CXQW7.cjs +0 -560
- package/dist/chunk-57EPKYID.cjs +0 -397
- package/dist/chunk-5MGEC3YG.js +0 -63
- package/dist/chunk-6EF52423.cjs +0 -249
- package/dist/chunk-6SCOKU3S.js +0 -109
- package/dist/chunk-6VUXD3CF.js +0 -119
- package/dist/chunk-7B76BSNK.cjs +0 -118
- package/dist/chunk-7Y6I2DSU.cjs +0 -101
- package/dist/chunk-A7S7E2EE.cjs +0 -308
- package/dist/chunk-AJZ6PMMZ.js +0 -16
- package/dist/chunk-AXGBL2IO.cjs +0 -251
- package/dist/chunk-B4TC6FBV.cjs +0 -678
- package/dist/chunk-BAV5T2E3.cjs +0 -15
- package/dist/chunk-BKIJBNIE.js +0 -21
- package/dist/chunk-BNIMTFK5.js +0 -59
- package/dist/chunk-BXW7YXB7.js +0 -1823
- package/dist/chunk-CFYZC4S6.js +0 -53
- package/dist/chunk-CSG4SCL3.js +0 -1587
- package/dist/chunk-CWQW7AKK.js +0 -676
- package/dist/chunk-DVMHRLKP.cjs +0 -16
- package/dist/chunk-EN7LVZBZ.js +0 -548
- package/dist/chunk-EV4Y7HCY.cjs +0 -26
- package/dist/chunk-F66VDYIZ.cjs +0 -18
- package/dist/chunk-FLJX37EL.cjs +0 -30
- package/dist/chunk-GKC3UDMC.cjs +0 -1623
- package/dist/chunk-H65I3GRZ.cjs +0 -106
- package/dist/chunk-HHYWB7VZ.js +0 -24
- package/dist/chunk-HNGGISFL.cjs +0 -65
- package/dist/chunk-HNSQAVSZ.cjs +0 -35
- package/dist/chunk-HSP6IWZK.js +0 -17
- package/dist/chunk-IDZS7J6T.js +0 -242
- package/dist/chunk-JS6R55VL.js +0 -302
- package/dist/chunk-JZVT5FK7.js +0 -232
- package/dist/chunk-KHO2SBNA.cjs +0 -16
- package/dist/chunk-KIDJCMNJ.js +0 -33
- package/dist/chunk-KOLEURVT.cjs +0 -38
- package/dist/chunk-L4V53MQK.cjs +0 -269
- package/dist/chunk-L5RDAVVH.js +0 -14
- package/dist/chunk-NODTV4F3.js +0 -16
- package/dist/chunk-NYK5K3V2.cjs +0 -211
- package/dist/chunk-ODUO3RTL.cjs +0 -113
- package/dist/chunk-ONZFBJVW.js +0 -14
- package/dist/chunk-PFXCTE37.js +0 -28
- package/dist/chunk-PPST7QAQ.js +0 -587
- package/dist/chunk-Q5IMYDFL.cjs +0 -33
- package/dist/chunk-QFFBIOJ4.js +0 -31
- package/dist/chunk-QNKGP5DY.js +0 -14
- package/dist/chunk-RRQHMOPE.cjs +0 -19
- package/dist/chunk-RU5OSRBU.js +0 -95
- package/dist/chunk-SDMPEJ4F.js +0 -35
- package/dist/chunk-SYNL5IKP.js +0 -115
- package/dist/chunk-TCDOWZQE.js +0 -16
- package/dist/chunk-TQPGXGKB.cjs +0 -123
- package/dist/chunk-TULOI4GL.js +0 -370
- package/dist/chunk-UBHCP4N5.cjs +0 -36
- package/dist/chunk-UCHF3M34.cjs +0 -56
- package/dist/chunk-UDA26MCU.cjs +0 -16
- package/dist/chunk-V3C4FYZL.cjs +0 -18
- package/dist/chunk-VAAHZFBF.js +0 -32
- package/dist/chunk-VJDDGRIK.cjs +0 -16
- package/dist/chunk-WVSPXFTY.js +0 -14
- package/dist/chunk-WYP76WXB.js +0 -101
- package/dist/chunk-YDE4ZBB7.cjs +0 -237
- package/dist/chunk-YKQEOO7C.cjs +0 -23
- package/dist/chunk-YSZC56SZ.js +0 -264
- package/dist/chunk-YWHHVDT4.js +0 -13
- package/dist/index.d.ts +0 -24
- package/dist/isPlainObject-DTJVV2Kf.d.ts +0 -536
package/dist/chunk-CSG4SCL3.js
DELETED
|
@@ -1,1587 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* ====================================================
|
|
3
|
-
* Rzl Utils-JS.
|
|
4
|
-
* ----------------------------------------------------
|
|
5
|
-
* Version: 3.12.0.
|
|
6
|
-
* Author: Rizalvin Dwiky.
|
|
7
|
-
* Repository: https://github.com/rzl-zone/utils-js.
|
|
8
|
-
* ====================================================
|
|
9
|
-
*/
|
|
10
|
-
var isBoolean = (value) => {
|
|
11
|
-
return typeof value === "boolean";
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
var isFunction = (value) => {
|
|
15
|
-
return typeof value === "function";
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
function isNil(value) {
|
|
19
|
-
return value == null;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function isArray(value) {
|
|
23
|
-
return Array.isArray(value);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function isObject(value) {
|
|
27
|
-
return typeof value === "object" && !isNil(value) && !isArray(value);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function isPlainObject(value) {
|
|
31
|
-
if (!isObject(value)) return false;
|
|
32
|
-
const proto = Object.getPrototypeOf(value);
|
|
33
|
-
return proto === Object.prototype || proto === null;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
var isString = (value) => {
|
|
37
|
-
return typeof value === "string";
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
function isNumberObject(value) {
|
|
41
|
-
return isObject(value) && Object.prototype.toString.call(value) === "[object Number]";
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function isNaN(value) {
|
|
45
|
-
return typeof value === "number" ? Number.isNaN(value) : isNumberObject(value) && Number.isNaN(value.valueOf());
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
var isNull = (val) => val === null;
|
|
49
|
-
|
|
50
|
-
var assertIsBoolean = (value, options = {}) => {
|
|
51
|
-
if (isBoolean(value)) return;
|
|
52
|
-
resolveErrorMessageAssertions({
|
|
53
|
-
value,
|
|
54
|
-
options,
|
|
55
|
-
requiredValidType: "boolean"
|
|
56
|
-
});
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
var isNumber = (value, options = {}) => {
|
|
60
|
-
assertIsPlainObject(options, {
|
|
61
|
-
message: ({ currentType, validType }) => `Second parameter (\`options\`) must be of type \`${validType}\`, but received: \`${currentType}\`.`
|
|
62
|
-
});
|
|
63
|
-
const includeNaN = isPlainObject(options) && isBoolean(options.includeNaN) ? options.includeNaN : false;
|
|
64
|
-
assertIsBoolean(includeNaN, {
|
|
65
|
-
message: ({ currentType, validType }) => `Parameter \`includeNaN\` property of the \`options\` (second parameter) must be of type \`${validType}\`, but received: \`${currentType}\`.`
|
|
66
|
-
});
|
|
67
|
-
const aNumber = typeof value === "number";
|
|
68
|
-
return includeNaN ? aNumber : aNumber && !Number.isNaN(value);
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
var isSymbol = (value) => {
|
|
72
|
-
return typeof value === "symbol";
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
var isUndefined = (value) => {
|
|
76
|
-
return typeof value === "undefined";
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
function isObjectOrArray(value) {
|
|
80
|
-
return isArray(value) || isObject(value);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
function hasOwnProp(obj, key, options = {}) {
|
|
84
|
-
if (!isString(obj) && !isObjectOrArray(obj) && !isFunction(obj)) return false;
|
|
85
|
-
assertIsPlainObject(options, {
|
|
86
|
-
message: ({ currentType, validType }) => `Third parameter (\`options\`) must be of type \`${validType}\`, but received: \`${currentType}\`.`
|
|
87
|
-
});
|
|
88
|
-
const discardUndefined = options.discardUndefined === void 0 ? true : options.discardUndefined;
|
|
89
|
-
const discardNull = options.discardNull === void 0 ? false : options.discardNull;
|
|
90
|
-
assertIsBoolean(discardUndefined, {
|
|
91
|
-
message: ({ currentType, validType }) => `Parameter \`discardUndefined\` property of the \`options\` (third parameter) must be of type \`${validType}\`, but received: \`${currentType}\`.`
|
|
92
|
-
});
|
|
93
|
-
assertIsBoolean(discardNull, {
|
|
94
|
-
message: ({ currentType, validType }) => `Parameter \`discardNull\` property of the \`options\` (third parameter) must be of type \`${validType}\`, but received: \`${currentType}\`.`
|
|
95
|
-
});
|
|
96
|
-
const path = [];
|
|
97
|
-
if (isString(key) && key.trim().length > 0 || isNumber(key, { includeNaN: true })) {
|
|
98
|
-
const strKey = isNumber(key, { includeNaN: true }) ? String(key) : key;
|
|
99
|
-
strKey.split(".").forEach((k) => {
|
|
100
|
-
const bracketMatch = k.match(/^\[(\d+)\]$/);
|
|
101
|
-
const symbolMatch = k.match(/^Symbol\((.+)\)$/);
|
|
102
|
-
if (bracketMatch) path.push(Number(bracketMatch[1]));
|
|
103
|
-
else if (symbolMatch) path.push(Symbol.for(symbolMatch[1]));
|
|
104
|
-
else if (!isNaN(Number(k))) path.push(Number(k));
|
|
105
|
-
else path.push(k);
|
|
106
|
-
});
|
|
107
|
-
} else if (isSymbol(key)) {
|
|
108
|
-
path.push(key);
|
|
109
|
-
} else {
|
|
110
|
-
return false;
|
|
111
|
-
}
|
|
112
|
-
let current = isString(obj) && obj.trim().length > 0 ? Object(obj) : obj;
|
|
113
|
-
for (const k of path) {
|
|
114
|
-
if (isString(k) && k.trim().length > 0 || isNumber(k, { includeNaN: true })) {
|
|
115
|
-
if (isNull(current) || !Object.prototype.hasOwnProperty.call(current, k)) {
|
|
116
|
-
return false;
|
|
117
|
-
}
|
|
118
|
-
current = current[k];
|
|
119
|
-
} else if (isSymbol(k)) {
|
|
120
|
-
if (isNull(current) || typeof current !== "object" && !isFunction(current)) {
|
|
121
|
-
return false;
|
|
122
|
-
}
|
|
123
|
-
const symbols = Object.getOwnPropertySymbols(current);
|
|
124
|
-
const matched = symbols.find((s) => s === k || s.description === k.description);
|
|
125
|
-
if (!matched) return false;
|
|
126
|
-
current = current[matched];
|
|
127
|
-
} else {
|
|
128
|
-
return false;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
if (discardUndefined && isUndefined(current)) return false;
|
|
132
|
-
if (discardNull && isNull(current)) return false;
|
|
133
|
-
return true;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
var isNonEmptyString = (value, options = {}) => {
|
|
137
|
-
if (!isString(value)) return false;
|
|
138
|
-
assertIsPlainObject(options, {
|
|
139
|
-
message: ({ currentType, validType }) => `Second parameter (\`options\`) must be of type \`${validType}\`, but received: \`${currentType}\`.`
|
|
140
|
-
});
|
|
141
|
-
const trim = hasOwnProp(options, "trim") ? options.trim : true;
|
|
142
|
-
assertIsBoolean(trim, {
|
|
143
|
-
message: ({ currentType, validType }) => `Parameter \`trim\` property of the \`options\` (second parameter) must be of type \`${validType}\`, but received: \`${currentType}\`.`
|
|
144
|
-
});
|
|
145
|
-
const str = trim ? value.trim() : value;
|
|
146
|
-
return str.length > 0;
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
var isError = (error) => {
|
|
150
|
-
return Object.prototype.toString.call(error) === "[object Error]" || error instanceof Error;
|
|
151
|
-
};
|
|
152
|
-
|
|
153
|
-
var isBuffer = (value) => {
|
|
154
|
-
return typeof Buffer !== "undefined" && typeof Buffer.isBuffer === "function" && Buffer.isBuffer(value);
|
|
155
|
-
};
|
|
156
|
-
|
|
157
|
-
function isStringObject(value) {
|
|
158
|
-
return isObject(value) && Object.prototype.toString.call(value) === "[object String]";
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
function isBooleanObject(value) {
|
|
162
|
-
return isObject(value) && Object.prototype.toString.call(value) === "[object Boolean]";
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
function isInfinityNumber(value) {
|
|
166
|
-
if (typeof value === "number" || isNumberObject(value)) {
|
|
167
|
-
const num = Number(value);
|
|
168
|
-
return num === Infinity || num === -Infinity;
|
|
169
|
-
}
|
|
170
|
-
return false;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
function isNonEmptyArray(value) {
|
|
174
|
-
return Array.isArray(value) && value.length > 0;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
function isSet(value) {
|
|
178
|
-
return Object.prototype.toString.call(value) === "[object Set]" || value instanceof Set;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
var validateCaseInputWordsCase = (input) => {
|
|
182
|
-
let result = "";
|
|
183
|
-
if (isArray(input)) {
|
|
184
|
-
result = input.map((x) => isNonEmptyString(x) ? x.trim() : "").filter((x) => x.length).join("-");
|
|
185
|
-
} else if (isNonEmptyString(input)) {
|
|
186
|
-
result = input.trim();
|
|
187
|
-
}
|
|
188
|
-
return result.split(/[^\p{L}\p{N}]+/u).filter(Boolean);
|
|
189
|
-
};
|
|
190
|
-
var validateCaseIgnoreWordsCase = (ignoreWord) => {
|
|
191
|
-
const result = /* @__PURE__ */ new Set([]);
|
|
192
|
-
const normalizeWord = (word) => word.trim().split(/[^\p{L}\p{N}]+/u).filter(Boolean).join("");
|
|
193
|
-
if (isNonEmptyString(ignoreWord)) {
|
|
194
|
-
const clean = normalizeWord(ignoreWord);
|
|
195
|
-
if (clean) result.add(clean);
|
|
196
|
-
}
|
|
197
|
-
if (isNonEmptyArray(ignoreWord)) {
|
|
198
|
-
ignoreWord.forEach((w) => {
|
|
199
|
-
if (isNonEmptyString(w)) {
|
|
200
|
-
const clean = normalizeWord(w);
|
|
201
|
-
if (clean) result.add(clean);
|
|
202
|
-
}
|
|
203
|
-
});
|
|
204
|
-
}
|
|
205
|
-
if (isSet(ignoreWord)) {
|
|
206
|
-
ignoreWord.forEach((w) => {
|
|
207
|
-
if (isNonEmptyString(w)) {
|
|
208
|
-
const clean = normalizeWord(w);
|
|
209
|
-
if (clean) result.add(clean);
|
|
210
|
-
}
|
|
211
|
-
});
|
|
212
|
-
}
|
|
213
|
-
return result;
|
|
214
|
-
};
|
|
215
|
-
|
|
216
|
-
var slugify = (input, ignoreWord) => {
|
|
217
|
-
if (!isNonEmptyArray(input) && !isNonEmptyString(input)) return "";
|
|
218
|
-
const wordsValidated = validateCaseInputWordsCase(input);
|
|
219
|
-
const ignoreWordsValidated = validateCaseIgnoreWordsCase(ignoreWord);
|
|
220
|
-
const slug = wordsValidated.map((word) => {
|
|
221
|
-
if (ignoreWordsValidated.has(word)) return word;
|
|
222
|
-
return word.toLowerCase();
|
|
223
|
-
}).join("-");
|
|
224
|
-
return slug.replace(/^-+|-+$/g, "");
|
|
225
|
-
};
|
|
226
|
-
|
|
227
|
-
var toDotCase = (input, ignoreWord) => {
|
|
228
|
-
if (!isNonEmptyArray(input) && !isNonEmptyString(input)) return "";
|
|
229
|
-
const wordsValidated = validateCaseInputWordsCase(input);
|
|
230
|
-
const ignoreWordsValidated = validateCaseIgnoreWordsCase(ignoreWord);
|
|
231
|
-
return wordsValidated.map((word) => {
|
|
232
|
-
if (ignoreWordsValidated.has(word)) return word;
|
|
233
|
-
return word.toLowerCase();
|
|
234
|
-
}).join(".");
|
|
235
|
-
};
|
|
236
|
-
|
|
237
|
-
var toCamelCase = (input, ignoreWord) => {
|
|
238
|
-
if (!isNonEmptyArray(input) && !isNonEmptyString(input)) return "";
|
|
239
|
-
const wordsValidated = validateCaseInputWordsCase(input);
|
|
240
|
-
const ignoreWordsValidated = validateCaseIgnoreWordsCase(ignoreWord);
|
|
241
|
-
return wordsValidated.map((word, index) => {
|
|
242
|
-
if (ignoreWordsValidated.has(word)) return word;
|
|
243
|
-
return index === 0 ? word.toLowerCase() : word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();
|
|
244
|
-
}).join("");
|
|
245
|
-
};
|
|
246
|
-
|
|
247
|
-
var toKebabCase = (input, ignoreWord) => {
|
|
248
|
-
if (!isNonEmptyArray(input) && !isNonEmptyString(input)) return "";
|
|
249
|
-
const wordsValidated = validateCaseInputWordsCase(input);
|
|
250
|
-
const ignoreWordsValidated = validateCaseIgnoreWordsCase(ignoreWord);
|
|
251
|
-
return wordsValidated.map((word) => {
|
|
252
|
-
if (ignoreWordsValidated.has(word)) return word;
|
|
253
|
-
return word.toLowerCase();
|
|
254
|
-
}).join("-");
|
|
255
|
-
};
|
|
256
|
-
|
|
257
|
-
var toSnakeCase = (input, ignoreWord) => {
|
|
258
|
-
if (!isNonEmptyArray(input) && !isNonEmptyString(input)) return "";
|
|
259
|
-
const wordsValidated = validateCaseInputWordsCase(input);
|
|
260
|
-
const ignoreWordsValidated = validateCaseIgnoreWordsCase(ignoreWord);
|
|
261
|
-
return wordsValidated.map((word) => {
|
|
262
|
-
if (ignoreWordsValidated.has(word)) return word;
|
|
263
|
-
return word.toLowerCase();
|
|
264
|
-
}).join("_");
|
|
265
|
-
};
|
|
266
|
-
|
|
267
|
-
var toLowerCase = (input, ignoreWord) => {
|
|
268
|
-
if (!isNonEmptyArray(input) && !isNonEmptyString(input)) return "";
|
|
269
|
-
const wordsValidated = validateCaseInputWordsCase(input);
|
|
270
|
-
const ignoreWordsValidated = validateCaseIgnoreWordsCase(ignoreWord);
|
|
271
|
-
return wordsValidated.map((word) => {
|
|
272
|
-
if (ignoreWordsValidated.has(word)) return word;
|
|
273
|
-
return word.toLowerCase();
|
|
274
|
-
}).join(" ");
|
|
275
|
-
};
|
|
276
|
-
|
|
277
|
-
var toPascalCase = (input, ignoreWord) => {
|
|
278
|
-
if (!isNonEmptyArray(input) && !isNonEmptyString(input)) return "";
|
|
279
|
-
const wordsValidated = validateCaseInputWordsCase(input);
|
|
280
|
-
const ignoreWordsValidated = validateCaseIgnoreWordsCase(ignoreWord);
|
|
281
|
-
return wordsValidated.map((word) => {
|
|
282
|
-
if (ignoreWordsValidated.has(word)) return word;
|
|
283
|
-
return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();
|
|
284
|
-
}).join("");
|
|
285
|
-
};
|
|
286
|
-
|
|
287
|
-
var toPascalCaseSpace = (input, ignoreWord) => {
|
|
288
|
-
if (!isNonEmptyArray(input) && !isNonEmptyString(input)) return "";
|
|
289
|
-
const wordsValidated = validateCaseInputWordsCase(input);
|
|
290
|
-
const ignoreWordsValidated = validateCaseIgnoreWordsCase(ignoreWord);
|
|
291
|
-
return wordsValidated.map((word) => {
|
|
292
|
-
if (ignoreWordsValidated.has(word)) return word;
|
|
293
|
-
return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();
|
|
294
|
-
}).join(" ");
|
|
295
|
-
};
|
|
296
|
-
|
|
297
|
-
var PreciseType = class _PreciseType {
|
|
298
|
-
/** ----------------------------------------------------------
|
|
299
|
-
* * ***Mapping table of JavaScript built-in and environment-specific types.***
|
|
300
|
-
* ----------------------------------------------------------
|
|
301
|
-
* - **Behavior:**
|
|
302
|
-
* - Maps internal or native type identifiers to **human-readable names** (usually PascalCase).
|
|
303
|
-
* - Keys are normalized to lowercase and stripped of spaces, dashes, or underscores.
|
|
304
|
-
* - Extend or modify entries to match your environment or platform.
|
|
305
|
-
*
|
|
306
|
-
* - **⚠️ Internal:**
|
|
307
|
-
* - Used internally by {@link getPreciseType | `getPreciseType`}.
|
|
308
|
-
* - Not intended for direct use in application code.
|
|
309
|
-
*
|
|
310
|
-
* @internal
|
|
311
|
-
*/
|
|
312
|
-
static FIXES_RAW = Object.freeze({
|
|
313
|
-
// primitives
|
|
314
|
-
string: "String",
|
|
315
|
-
number: "Number",
|
|
316
|
-
boolean: "Boolean",
|
|
317
|
-
bigint: "Bigint",
|
|
318
|
-
symbol: "Symbol",
|
|
319
|
-
undefined: "Undefined",
|
|
320
|
-
null: "Null",
|
|
321
|
-
regexp: "Reg Exp",
|
|
322
|
-
// reflect / proxy / atomics
|
|
323
|
-
reflect: "Reflect",
|
|
324
|
-
proxy: "Proxy",
|
|
325
|
-
atomics: "Atomics",
|
|
326
|
-
// core / objects
|
|
327
|
-
array: "Array",
|
|
328
|
-
object: "Object",
|
|
329
|
-
function: "Function",
|
|
330
|
-
arguments: "Arguments",
|
|
331
|
-
// functions
|
|
332
|
-
asyncfunction: "Async Function",
|
|
333
|
-
generatorfunction: "Generator Function",
|
|
334
|
-
asyncgeneratorfunction: "Async Generator Function",
|
|
335
|
-
generator: "Generator",
|
|
336
|
-
promise: "Promise",
|
|
337
|
-
// errors
|
|
338
|
-
evalerror: "Eval Error",
|
|
339
|
-
rangeerror: "Range Error",
|
|
340
|
-
referenceerror: "Reference Error",
|
|
341
|
-
syntaxerror: "Syntax Error",
|
|
342
|
-
typeerror: "Type Error",
|
|
343
|
-
urierror: "URI Error",
|
|
344
|
-
aggregateerror: "Aggregate Error",
|
|
345
|
-
error: "Error",
|
|
346
|
-
// typed arrays & binary
|
|
347
|
-
int8array: "Int 8 Array",
|
|
348
|
-
uint8array: "Uint 8 Array",
|
|
349
|
-
uint8clampedarray: "Uint 8 Clamped Array",
|
|
350
|
-
int16array: "Int 16 Array",
|
|
351
|
-
uint16array: "Uint 16 Array",
|
|
352
|
-
int32array: "Int 32 Array",
|
|
353
|
-
uint32array: "Uint 32 Array",
|
|
354
|
-
float32array: "Float 32 Array",
|
|
355
|
-
float64array: "Float 64 Array",
|
|
356
|
-
bigint64array: "Big Int 64 Array",
|
|
357
|
-
biguint64array: "Big Uint 64 Array",
|
|
358
|
-
arraybuffer: "Array Buffer",
|
|
359
|
-
sharedarraybuffer: "Shared Array Buffer",
|
|
360
|
-
dataview: "Data View",
|
|
361
|
-
arraybufferview: "Array Buffer View",
|
|
362
|
-
// collections
|
|
363
|
-
map: "Map",
|
|
364
|
-
set: "Set",
|
|
365
|
-
weakmap: "Weak Map",
|
|
366
|
-
weakset: "Weak Set",
|
|
367
|
-
// iterators (note: toString tag can be "Map Iterator" etc.)
|
|
368
|
-
mapiterator: "Map Iterator",
|
|
369
|
-
weakmapiterator: "Weak Map Iterator",
|
|
370
|
-
setiterator: "Set Iterator",
|
|
371
|
-
weaksetiterator: "Weak Set Iterator",
|
|
372
|
-
arrayiterator: "Array Iterator",
|
|
373
|
-
stringiterator: "String Iterator",
|
|
374
|
-
asynciterator: "Async Iterator",
|
|
375
|
-
iteratorresult: "Iterator Result",
|
|
376
|
-
arrayiteratorresult: "Array Iterator Result",
|
|
377
|
-
// streams / fetch / web
|
|
378
|
-
readablestream: "Readable Stream",
|
|
379
|
-
writablestream: "Writable Stream",
|
|
380
|
-
transformstream: "Transform Stream",
|
|
381
|
-
readablestreamdefaultreader: "Readable Stream Default Reader",
|
|
382
|
-
writablestreamdefaultwriter: "Writable Stream Default Writer",
|
|
383
|
-
readablestreamdefaultcontroller: "Readable Stream Default Controller",
|
|
384
|
-
transformstreamdefaultcontroller: "Transform Stream Default Controller",
|
|
385
|
-
abortcontroller: "Abort Controller",
|
|
386
|
-
abortsignal: "Abort Signal",
|
|
387
|
-
fetch: "fetch",
|
|
388
|
-
request: "Request",
|
|
389
|
-
response: "Response",
|
|
390
|
-
headers: "Headers",
|
|
391
|
-
formdata: "FormData",
|
|
392
|
-
blob: "Blob",
|
|
393
|
-
file: "File",
|
|
394
|
-
filelist: "FileList",
|
|
395
|
-
filereader: "FileReader",
|
|
396
|
-
// intl
|
|
397
|
-
intl: "Intl",
|
|
398
|
-
collator: "Intl. Collator",
|
|
399
|
-
datetimeformat: "Intl. Date Time Format",
|
|
400
|
-
displaynames: "Intl. Display Names",
|
|
401
|
-
listformat: "Intl. List Format",
|
|
402
|
-
locale: "Intl. Locale",
|
|
403
|
-
numberformat: "Intl. Number Format",
|
|
404
|
-
pluralrules: "Intl. Plural Rules",
|
|
405
|
-
relativetimeformat: "Intl. Relative Time Format",
|
|
406
|
-
segmenter: "Intl. Segmenter",
|
|
407
|
-
// es2021+
|
|
408
|
-
weakref: "Weak Ref",
|
|
409
|
-
urlpattern: "URLPattern",
|
|
410
|
-
structuredclone: "structured Clone",
|
|
411
|
-
finalizationregistry: "Finalization Registry",
|
|
412
|
-
// performance / observers
|
|
413
|
-
performance: "Performance",
|
|
414
|
-
performanceobserver: "Performance Observer",
|
|
415
|
-
performanceentry: "Performance Entry",
|
|
416
|
-
performancemark: "Performance Mark",
|
|
417
|
-
performancemeasure: "Performance Measure",
|
|
418
|
-
// webassembly
|
|
419
|
-
webassembly: "Web Assembly",
|
|
420
|
-
wasmmodule: "WebAssembly. Module",
|
|
421
|
-
wasminstance: "WebAssembly. Instance",
|
|
422
|
-
wasmmemory: "WebAssembly. Memory",
|
|
423
|
-
wasmtable: "WebAssembly. Table",
|
|
424
|
-
// node-ish / common hosts
|
|
425
|
-
buffer: "Buffer",
|
|
426
|
-
process: "Process",
|
|
427
|
-
eventemitter: "Event Emitter",
|
|
428
|
-
stream: "Stream",
|
|
429
|
-
fs: "fs",
|
|
430
|
-
path: "path",
|
|
431
|
-
url: "URL",
|
|
432
|
-
urlsearchparams: "URL Search Params",
|
|
433
|
-
// DOM basics
|
|
434
|
-
node: "Node",
|
|
435
|
-
element: "Element",
|
|
436
|
-
htmlelement: "HTML Element",
|
|
437
|
-
svgelement: "SVG Element",
|
|
438
|
-
document: "Document",
|
|
439
|
-
documentfragment: "Document Fragment",
|
|
440
|
-
shadowroot: "Shadow Root",
|
|
441
|
-
nodelist: "Node List",
|
|
442
|
-
htmlcollection: "HTML Collection",
|
|
443
|
-
// observers / misc DOM
|
|
444
|
-
resizeobserver: "Resize Observer",
|
|
445
|
-
mutationobserver: "Mutation Observer",
|
|
446
|
-
intersectionobserver: "Intersection Observer",
|
|
447
|
-
// Reflection / Symbolic
|
|
448
|
-
symboliterator: "Symbol. Iterator",
|
|
449
|
-
symbolasynciterator: "Symbol. Async Iterator",
|
|
450
|
-
symboltostringtag: "Symbol. To String Tag",
|
|
451
|
-
symbolspecies: "Symbol. Species",
|
|
452
|
-
symbolhasinstance: "Symbol. Has Instance",
|
|
453
|
-
symbolisconcatspreadable: "Symbol. Is Concat Spreadable",
|
|
454
|
-
symbolunscopables: "Symbol. Unscopables",
|
|
455
|
-
symbolmatch: "Symbol. Match",
|
|
456
|
-
symbolreplace: "Symbol. Replace",
|
|
457
|
-
symbolsearch: "Symbol. Search",
|
|
458
|
-
symbolsplit: "Symbol. Split",
|
|
459
|
-
symboltoprimitive: "Symbol. To Primitive",
|
|
460
|
-
symbolmatchall: "Symbol. Match All",
|
|
461
|
-
symbolarguments: "Symbol. Arguments",
|
|
462
|
-
// deprecated
|
|
463
|
-
// Numbers & Math
|
|
464
|
-
math: "Math",
|
|
465
|
-
bigintconstructor: "Bigint Constructor",
|
|
466
|
-
numberconstructor: "Number Constructor",
|
|
467
|
-
stringconstructor: "String Constructor",
|
|
468
|
-
booleanconstructor: "Boolean Constructor",
|
|
469
|
-
// URL / Networking (modern web)
|
|
470
|
-
formdataevent: "Form Data Event",
|
|
471
|
-
customevent: "Custom Event",
|
|
472
|
-
messagechannel: "Message Channel",
|
|
473
|
-
messageport: "Message Port",
|
|
474
|
-
messageevent: "Message Event",
|
|
475
|
-
websocket: "Web Socket",
|
|
476
|
-
eventsource: "Event Source",
|
|
477
|
-
// Storage APIs
|
|
478
|
-
indexeddb: "IndexedDB",
|
|
479
|
-
idbrequest: "IDB Request",
|
|
480
|
-
idbtransaction: "IDB Transaction",
|
|
481
|
-
idbobjectstore: "IDB Object Store",
|
|
482
|
-
idbcursor: "IDB Cursor",
|
|
483
|
-
localstorage: "Local Storage",
|
|
484
|
-
sessionstorage: "Session Storage",
|
|
485
|
-
// Navigator / Browser APIs
|
|
486
|
-
navigator: "Navigator",
|
|
487
|
-
geolocation: "Geolocation",
|
|
488
|
-
clipboard: "Clipboard",
|
|
489
|
-
notification: "Notification",
|
|
490
|
-
// Canvas / Graphics
|
|
491
|
-
canvas: "Canvas",
|
|
492
|
-
canvasrenderingcontext2d: "Canvas Rendering Context 2D",
|
|
493
|
-
offscreencanvas: "Offscreen Canvas",
|
|
494
|
-
webglrenderingcontext: "WebGL Rendering Context",
|
|
495
|
-
imagedata: "Image Data",
|
|
496
|
-
imagebitmap: "Image Bitmap",
|
|
497
|
-
// Media
|
|
498
|
-
mediastream: "Media Stream",
|
|
499
|
-
mediarecorder: "Media Recorder",
|
|
500
|
-
mediastreamtrack: "Media Stream Track",
|
|
501
|
-
audiocontext: "Audio Context",
|
|
502
|
-
audiobuffer: "Audio Buffer",
|
|
503
|
-
audioworklet: "Audio Worklet",
|
|
504
|
-
// Workers
|
|
505
|
-
worker: "Worker",
|
|
506
|
-
sharedworker: "Shared Worker",
|
|
507
|
-
serviceworker: "Service Worker",
|
|
508
|
-
workerglobalscope: "Worker Global Scope",
|
|
509
|
-
// Structured Clone / Transferable
|
|
510
|
-
structuredcloneerror: "Structured Clone Error",
|
|
511
|
-
transferable: "Transferable",
|
|
512
|
-
// Testing / Diagnostics
|
|
513
|
-
report: "Report",
|
|
514
|
-
console: "Console",
|
|
515
|
-
diagnosticreport: "Diagnostic Report",
|
|
516
|
-
// Misc
|
|
517
|
-
domrect: "DOM Rect",
|
|
518
|
-
dompoint: "DOM Point",
|
|
519
|
-
dommatrix: "DOM Matrix",
|
|
520
|
-
domparser: "DOM Parser",
|
|
521
|
-
xmlhttprequest: "XML HTTP Request",
|
|
522
|
-
customelementregistry: "Custom Element Registry",
|
|
523
|
-
// additions-ons
|
|
524
|
-
text: "Text",
|
|
525
|
-
comment: "Comment",
|
|
526
|
-
animation: "Animation",
|
|
527
|
-
documenttype: "Document Type",
|
|
528
|
-
characterdata: "Character Data",
|
|
529
|
-
animationevent: "Animation Event",
|
|
530
|
-
customemmetregistry: "Custom Emmet Registry",
|
|
531
|
-
websocketmessageevent: "WebSocket Message Event"
|
|
532
|
-
});
|
|
533
|
-
/** ----------------------------------------------------------
|
|
534
|
-
* * ***List of JavaScript special numeric values.***
|
|
535
|
-
* ----------------------------------------------------------
|
|
536
|
-
*
|
|
537
|
-
* - Contains special values recognized by {@link getPreciseType | `getPreciseType`},
|
|
538
|
-
* such as `"Infinity"`, `"-Infinity"`, and `"NaN"`.
|
|
539
|
-
*
|
|
540
|
-
* - **⚠️ Internal:**
|
|
541
|
-
* - Used by {@link getPreciseType | `getPreciseType`} for numeric edge-case detection.
|
|
542
|
-
*
|
|
543
|
-
* @internal
|
|
544
|
-
*/
|
|
545
|
-
static SPECIAL_TYPE = Object.freeze([
|
|
546
|
-
"-Infinity",
|
|
547
|
-
"Infinity",
|
|
548
|
-
"NaN"
|
|
549
|
-
]);
|
|
550
|
-
/** ----------------------------------------------------------
|
|
551
|
-
* * ***List of acronyms to keep uppercase in formatted output.***
|
|
552
|
-
* ----------------------------------------------------------
|
|
553
|
-
*
|
|
554
|
-
* - **Behavior:**
|
|
555
|
-
* - Prevents transformations (like camelCase or kebab-case) from altering
|
|
556
|
-
* known acronyms such as `HTML`, `URL`, `API`, etc.
|
|
557
|
-
* - Extend this list if you want more acronyms to remain uppercase.
|
|
558
|
-
*
|
|
559
|
-
* - **⚠️ Internal:**
|
|
560
|
-
* - Used internally by {@link getPreciseType | `getPreciseType`} and related formatters.
|
|
561
|
-
*
|
|
562
|
-
* @internal
|
|
563
|
-
*/
|
|
564
|
-
static ACRONYMS = Object.freeze([
|
|
565
|
-
// Web & Protocols
|
|
566
|
-
"URI",
|
|
567
|
-
"URL",
|
|
568
|
-
"URN",
|
|
569
|
-
"HTTP",
|
|
570
|
-
"HTTPS",
|
|
571
|
-
"FTP",
|
|
572
|
-
"FTPS",
|
|
573
|
-
"SFTP",
|
|
574
|
-
"SSH",
|
|
575
|
-
"SMTP",
|
|
576
|
-
"POP3",
|
|
577
|
-
"IMAP",
|
|
578
|
-
"WS",
|
|
579
|
-
"WSS",
|
|
580
|
-
"TCP",
|
|
581
|
-
"UDP",
|
|
582
|
-
"IP",
|
|
583
|
-
"ICMP",
|
|
584
|
-
"ARP",
|
|
585
|
-
"RTP",
|
|
586
|
-
"RTSP",
|
|
587
|
-
"SIP",
|
|
588
|
-
// Web APIs & Standards
|
|
589
|
-
"HTML",
|
|
590
|
-
"XHTML",
|
|
591
|
-
"XML",
|
|
592
|
-
"WBR",
|
|
593
|
-
"CSS",
|
|
594
|
-
"SVG",
|
|
595
|
-
"JSON",
|
|
596
|
-
"JSONP",
|
|
597
|
-
"DOM",
|
|
598
|
-
"IDB",
|
|
599
|
-
"DB",
|
|
600
|
-
"RTC",
|
|
601
|
-
"ICE",
|
|
602
|
-
"TLS",
|
|
603
|
-
"SSL",
|
|
604
|
-
"CORS",
|
|
605
|
-
"WASM",
|
|
606
|
-
"CSR",
|
|
607
|
-
"SSR",
|
|
608
|
-
"PWA",
|
|
609
|
-
"DPI",
|
|
610
|
-
"CDN",
|
|
611
|
-
// Programming / JS Ecosystem
|
|
612
|
-
"JS",
|
|
613
|
-
"TS",
|
|
614
|
-
"JSX",
|
|
615
|
-
"TSX",
|
|
616
|
-
"CLI",
|
|
617
|
-
"API",
|
|
618
|
-
"SDK",
|
|
619
|
-
"UI",
|
|
620
|
-
"UX",
|
|
621
|
-
"OS",
|
|
622
|
-
"ID",
|
|
623
|
-
"UUID",
|
|
624
|
-
"PID",
|
|
625
|
-
"NPM",
|
|
626
|
-
"YARN",
|
|
627
|
-
"ESM",
|
|
628
|
-
"CJS",
|
|
629
|
-
"BOM",
|
|
630
|
-
"MVC",
|
|
631
|
-
"MVVM",
|
|
632
|
-
"ORM",
|
|
633
|
-
"DAO",
|
|
634
|
-
"CRUD",
|
|
635
|
-
"FIFO",
|
|
636
|
-
"LIFO",
|
|
637
|
-
"OOP",
|
|
638
|
-
"FP",
|
|
639
|
-
"REPL",
|
|
640
|
-
// Data Formats & Types
|
|
641
|
-
"CSV",
|
|
642
|
-
"TSV",
|
|
643
|
-
"SQL",
|
|
644
|
-
"YAML",
|
|
645
|
-
"JSON",
|
|
646
|
-
"MD",
|
|
647
|
-
"INI",
|
|
648
|
-
"PDF",
|
|
649
|
-
"XLS",
|
|
650
|
-
"XLSX",
|
|
651
|
-
"RTF",
|
|
652
|
-
"XML",
|
|
653
|
-
"BMP",
|
|
654
|
-
"GIF",
|
|
655
|
-
"PNG",
|
|
656
|
-
"JPEG",
|
|
657
|
-
"WEBP",
|
|
658
|
-
"MP3",
|
|
659
|
-
"MP4",
|
|
660
|
-
"AVI",
|
|
661
|
-
"MOV",
|
|
662
|
-
"FLAC",
|
|
663
|
-
"MKV",
|
|
664
|
-
"WAV",
|
|
665
|
-
// Common Abbreviations
|
|
666
|
-
"URLSearchParams",
|
|
667
|
-
"XHR",
|
|
668
|
-
"2D",
|
|
669
|
-
"3D",
|
|
670
|
-
"GL",
|
|
671
|
-
"WebGL",
|
|
672
|
-
"TTL",
|
|
673
|
-
"UID",
|
|
674
|
-
"GID",
|
|
675
|
-
"MAC",
|
|
676
|
-
"IP",
|
|
677
|
-
"DNS",
|
|
678
|
-
"DHCP",
|
|
679
|
-
"VPN",
|
|
680
|
-
"LAN",
|
|
681
|
-
"WAN",
|
|
682
|
-
"SSID",
|
|
683
|
-
"IoT",
|
|
684
|
-
"API",
|
|
685
|
-
"SDK",
|
|
686
|
-
"CLI",
|
|
687
|
-
"LTS",
|
|
688
|
-
"EOL",
|
|
689
|
-
// Hardware & Infrastructure
|
|
690
|
-
"CPU",
|
|
691
|
-
"GPU",
|
|
692
|
-
"RAM",
|
|
693
|
-
"ROM",
|
|
694
|
-
"SSD",
|
|
695
|
-
"HDD",
|
|
696
|
-
"BIOS",
|
|
697
|
-
"USB",
|
|
698
|
-
"PCI",
|
|
699
|
-
"SATA",
|
|
700
|
-
"DIMM",
|
|
701
|
-
"DDR",
|
|
702
|
-
"VGA",
|
|
703
|
-
"HDMI",
|
|
704
|
-
"KVM",
|
|
705
|
-
"ASIC",
|
|
706
|
-
"FPGA",
|
|
707
|
-
"SoC",
|
|
708
|
-
"NAS",
|
|
709
|
-
"SAN",
|
|
710
|
-
// Networking
|
|
711
|
-
"TCP",
|
|
712
|
-
"UDP",
|
|
713
|
-
"IP",
|
|
714
|
-
"MAC",
|
|
715
|
-
"DNS",
|
|
716
|
-
"DHCP",
|
|
717
|
-
"VPN",
|
|
718
|
-
"LAN",
|
|
719
|
-
"WAN",
|
|
720
|
-
"SSID",
|
|
721
|
-
"NAT",
|
|
722
|
-
"QoS",
|
|
723
|
-
"MPLS",
|
|
724
|
-
"BGP",
|
|
725
|
-
"OSPF",
|
|
726
|
-
"ICMP",
|
|
727
|
-
"IGMP",
|
|
728
|
-
"LLDP",
|
|
729
|
-
"ARP",
|
|
730
|
-
"RARP",
|
|
731
|
-
// Security
|
|
732
|
-
"AES",
|
|
733
|
-
"RSA",
|
|
734
|
-
"OTP",
|
|
735
|
-
"MFA",
|
|
736
|
-
"PKI",
|
|
737
|
-
"VPN",
|
|
738
|
-
"IAM",
|
|
739
|
-
"ACL",
|
|
740
|
-
"CSP",
|
|
741
|
-
"XSS",
|
|
742
|
-
"CSRF",
|
|
743
|
-
"HSTS",
|
|
744
|
-
"WAF",
|
|
745
|
-
"DDoS",
|
|
746
|
-
"IDS",
|
|
747
|
-
"IPS",
|
|
748
|
-
"SOC",
|
|
749
|
-
"SIEM",
|
|
750
|
-
// Cloud / DevOps / Infrastructure
|
|
751
|
-
"AWS",
|
|
752
|
-
"GCP",
|
|
753
|
-
"AZURE",
|
|
754
|
-
"CI",
|
|
755
|
-
"CD",
|
|
756
|
-
"K8S",
|
|
757
|
-
"IaC",
|
|
758
|
-
"PaaS",
|
|
759
|
-
"SaaS",
|
|
760
|
-
"IaaS",
|
|
761
|
-
"API",
|
|
762
|
-
"CLI",
|
|
763
|
-
"SDK",
|
|
764
|
-
"REST",
|
|
765
|
-
"SOAP",
|
|
766
|
-
"JSON-RPC",
|
|
767
|
-
"gRPC",
|
|
768
|
-
"ELB",
|
|
769
|
-
"EKS",
|
|
770
|
-
"AKS",
|
|
771
|
-
"FaaS",
|
|
772
|
-
"CaaS",
|
|
773
|
-
// User Interface & Tools
|
|
774
|
-
"GUI",
|
|
775
|
-
"IDE",
|
|
776
|
-
"FAQ",
|
|
777
|
-
"UX",
|
|
778
|
-
"UI",
|
|
779
|
-
"CLI",
|
|
780
|
-
"API",
|
|
781
|
-
"SDK",
|
|
782
|
-
"LTS",
|
|
783
|
-
"EOL",
|
|
784
|
-
"WYSIWYG",
|
|
785
|
-
"CMS",
|
|
786
|
-
"CRM",
|
|
787
|
-
// Miscellaneous
|
|
788
|
-
"GPS",
|
|
789
|
-
"LED",
|
|
790
|
-
"OLED",
|
|
791
|
-
"LCD",
|
|
792
|
-
"RFID",
|
|
793
|
-
"NFC",
|
|
794
|
-
"CPU",
|
|
795
|
-
"GPU",
|
|
796
|
-
"AI",
|
|
797
|
-
"ML",
|
|
798
|
-
"DL",
|
|
799
|
-
"DB",
|
|
800
|
-
"SQL",
|
|
801
|
-
"NoSQL",
|
|
802
|
-
"ORM",
|
|
803
|
-
"JSON",
|
|
804
|
-
"XML",
|
|
805
|
-
"CSV",
|
|
806
|
-
"HTTP",
|
|
807
|
-
"HTTPS",
|
|
808
|
-
// Testing & QA
|
|
809
|
-
"TDD",
|
|
810
|
-
"BDD",
|
|
811
|
-
"CI",
|
|
812
|
-
"CD",
|
|
813
|
-
"QA",
|
|
814
|
-
"SLA",
|
|
815
|
-
"SLO",
|
|
816
|
-
"MTTR",
|
|
817
|
-
"MTBF",
|
|
818
|
-
"UAT",
|
|
819
|
-
"RPA",
|
|
820
|
-
// Business & Project Management
|
|
821
|
-
"KPI",
|
|
822
|
-
"OKR",
|
|
823
|
-
"ROI",
|
|
824
|
-
"RFP",
|
|
825
|
-
"SLA",
|
|
826
|
-
"CRM",
|
|
827
|
-
"ERP",
|
|
828
|
-
"PMO",
|
|
829
|
-
"SCRUM",
|
|
830
|
-
"KANBAN",
|
|
831
|
-
// Multimedia & Graphics
|
|
832
|
-
"FPS",
|
|
833
|
-
"HDR",
|
|
834
|
-
"VR",
|
|
835
|
-
"AR",
|
|
836
|
-
"3D",
|
|
837
|
-
"2D",
|
|
838
|
-
"MP3",
|
|
839
|
-
"MP4",
|
|
840
|
-
"GIF",
|
|
841
|
-
"PNG",
|
|
842
|
-
"JPEG",
|
|
843
|
-
"SVG",
|
|
844
|
-
"BMP",
|
|
845
|
-
"TIFF",
|
|
846
|
-
// Operating Systems & File Systems
|
|
847
|
-
"POSIX",
|
|
848
|
-
"NTFS",
|
|
849
|
-
"FAT",
|
|
850
|
-
"EXT",
|
|
851
|
-
"EXT4",
|
|
852
|
-
"APFS",
|
|
853
|
-
"HFS",
|
|
854
|
-
"ISO",
|
|
855
|
-
// Programming Languages & Tools
|
|
856
|
-
"HTML",
|
|
857
|
-
"CSS",
|
|
858
|
-
"JS",
|
|
859
|
-
"TS",
|
|
860
|
-
"PHP",
|
|
861
|
-
"SQL",
|
|
862
|
-
"JSON",
|
|
863
|
-
"XML",
|
|
864
|
-
"YAML",
|
|
865
|
-
"BASH",
|
|
866
|
-
"ZSH",
|
|
867
|
-
"JSON",
|
|
868
|
-
"YAML",
|
|
869
|
-
"INI",
|
|
870
|
-
"DOTENV",
|
|
871
|
-
// Containers & Virtualization
|
|
872
|
-
"VM",
|
|
873
|
-
"VMM",
|
|
874
|
-
"VPC",
|
|
875
|
-
"OCI",
|
|
876
|
-
"LXC",
|
|
877
|
-
"Docker",
|
|
878
|
-
"K8S",
|
|
879
|
-
"CRI",
|
|
880
|
-
"CNI"
|
|
881
|
-
]);
|
|
882
|
-
/** ----------------------------------------------------------
|
|
883
|
-
* * ***Normalized lookup table for type mapping.***
|
|
884
|
-
* ----------------------------------------------------------
|
|
885
|
-
*
|
|
886
|
-
* - **Behavior:**
|
|
887
|
-
* - Converts all keys from {@link FIXES_RAW | `FIXES_RAW`} into normalized form
|
|
888
|
-
* (lowercased and stripped of separators) for consistent lookup.
|
|
889
|
-
* - Values remain the formatted human-readable type names.
|
|
890
|
-
*
|
|
891
|
-
* - **⚠️ Internal:**
|
|
892
|
-
* - Helper table for {@link getPreciseType | `getPreciseType`} and related matchers.
|
|
893
|
-
*
|
|
894
|
-
* @internal
|
|
895
|
-
*/
|
|
896
|
-
static FIXES_CASTABLE_TABLE = Object.freeze(
|
|
897
|
-
Object.entries(_PreciseType.FIXES_RAW).reduce(
|
|
898
|
-
(acc, [k, v]) => {
|
|
899
|
-
acc[_PreciseType.normalizeKeyForCase(k)] = v;
|
|
900
|
-
return acc;
|
|
901
|
-
},
|
|
902
|
-
{}
|
|
903
|
-
)
|
|
904
|
-
);
|
|
905
|
-
/** @internal */
|
|
906
|
-
formatCase = "toKebabCase";
|
|
907
|
-
/** @internal */
|
|
908
|
-
useAcronyms = false;
|
|
909
|
-
constructor(params) {
|
|
910
|
-
this.formatCase = params?.formatCase;
|
|
911
|
-
this.useAcronyms = params?.useAcronyms;
|
|
912
|
-
}
|
|
913
|
-
/** @internal */
|
|
914
|
-
determineOptions(options) {
|
|
915
|
-
return {
|
|
916
|
-
formatCase: options?.formatCase || this.formatCase,
|
|
917
|
-
useAcronyms: options?.useAcronyms ?? this.useAcronyms
|
|
918
|
-
};
|
|
919
|
-
}
|
|
920
|
-
// ------------------------
|
|
921
|
-
// Helpers for DOM detection
|
|
922
|
-
// ------------------------
|
|
923
|
-
/** @internal */
|
|
924
|
-
getHtmlElementType(value, options) {
|
|
925
|
-
const { formatCase, useAcronyms } = this.determineOptions(options);
|
|
926
|
-
if (typeof HTMLElement === "undefined" || !(value instanceof HTMLElement))
|
|
927
|
-
return null;
|
|
928
|
-
const tagName = value.tagName;
|
|
929
|
-
const DEFAULTS = {
|
|
930
|
-
a: "Anchor",
|
|
931
|
-
abbr: "Abbreviation",
|
|
932
|
-
address: "Address",
|
|
933
|
-
area: "Area",
|
|
934
|
-
article: "Article",
|
|
935
|
-
aside: "Aside",
|
|
936
|
-
audio: "Audio",
|
|
937
|
-
b: "Bold",
|
|
938
|
-
base: "Base",
|
|
939
|
-
bdi: "BDI",
|
|
940
|
-
bdo: "BDO",
|
|
941
|
-
blockquote: "Blockquote",
|
|
942
|
-
body: "Body",
|
|
943
|
-
br: "Break",
|
|
944
|
-
button: "Button",
|
|
945
|
-
canvas: "Canvas",
|
|
946
|
-
caption: "Caption",
|
|
947
|
-
cite: "Cite",
|
|
948
|
-
code: "Code",
|
|
949
|
-
col: "Column",
|
|
950
|
-
colgroup: "Column Group",
|
|
951
|
-
data: "Data",
|
|
952
|
-
datalist: "Datalist",
|
|
953
|
-
dd: "Definition Description",
|
|
954
|
-
del: "Deleted Text",
|
|
955
|
-
details: "Details",
|
|
956
|
-
dfn: "Definition",
|
|
957
|
-
dialog: "Dialog",
|
|
958
|
-
div: "Div",
|
|
959
|
-
dl: "Definition List",
|
|
960
|
-
dt: "Definition Term",
|
|
961
|
-
em: "Emphasis",
|
|
962
|
-
embed: "Embed",
|
|
963
|
-
fieldset: "Fieldset",
|
|
964
|
-
figcaption: "Figcaption",
|
|
965
|
-
figure: "Figure",
|
|
966
|
-
footer: "Footer",
|
|
967
|
-
form: "Form",
|
|
968
|
-
h1: "Heading 1",
|
|
969
|
-
h2: "Heading 2",
|
|
970
|
-
h3: "Heading 3",
|
|
971
|
-
h4: "Heading 4",
|
|
972
|
-
h5: "Heading 5",
|
|
973
|
-
h6: "Heading 6",
|
|
974
|
-
head: "Head",
|
|
975
|
-
header: "Header",
|
|
976
|
-
hr: "Horizontal Rule",
|
|
977
|
-
html: "HTML",
|
|
978
|
-
i: "Italic",
|
|
979
|
-
iframe: "IFrame",
|
|
980
|
-
img: "Image",
|
|
981
|
-
input: "Input",
|
|
982
|
-
ins: "Inserted Text",
|
|
983
|
-
kbd: "Keyboard",
|
|
984
|
-
label: "Label",
|
|
985
|
-
legend: "Legend",
|
|
986
|
-
li: "List Item",
|
|
987
|
-
link: "Link",
|
|
988
|
-
main: "Main",
|
|
989
|
-
map: "Map",
|
|
990
|
-
mark: "Mark",
|
|
991
|
-
meta: "Meta",
|
|
992
|
-
meter: "Meter",
|
|
993
|
-
nav: "Nav",
|
|
994
|
-
noscript: "NoScript",
|
|
995
|
-
object: "Object",
|
|
996
|
-
ol: "Ordered List",
|
|
997
|
-
optgroup: "Option Group",
|
|
998
|
-
option: "Option",
|
|
999
|
-
output: "Output",
|
|
1000
|
-
p: "Paragraph",
|
|
1001
|
-
param: "Param",
|
|
1002
|
-
picture: "Picture",
|
|
1003
|
-
pre: "Preformatted",
|
|
1004
|
-
progress: "Progress",
|
|
1005
|
-
q: "Quote",
|
|
1006
|
-
rp: "RP",
|
|
1007
|
-
rt: "RT",
|
|
1008
|
-
ruby: "Ruby",
|
|
1009
|
-
s: "Strikethrough",
|
|
1010
|
-
samp: "Sample",
|
|
1011
|
-
script: "Script",
|
|
1012
|
-
section: "Section",
|
|
1013
|
-
select: "Select",
|
|
1014
|
-
small: "Small",
|
|
1015
|
-
source: "Source",
|
|
1016
|
-
span: "Span",
|
|
1017
|
-
strong: "Strong",
|
|
1018
|
-
style: "Style",
|
|
1019
|
-
sub: "Subscript",
|
|
1020
|
-
summary: "Summary",
|
|
1021
|
-
sup: "Superscript",
|
|
1022
|
-
table: "Table",
|
|
1023
|
-
tbody: "Table Body",
|
|
1024
|
-
td: "Table Data",
|
|
1025
|
-
template: "Template",
|
|
1026
|
-
textarea: "Textarea",
|
|
1027
|
-
tfoot: "Table Footer",
|
|
1028
|
-
th: "Table Header",
|
|
1029
|
-
thead: "Table Head",
|
|
1030
|
-
time: "Time",
|
|
1031
|
-
title: "Title",
|
|
1032
|
-
tr: "Table Row",
|
|
1033
|
-
track: "Track",
|
|
1034
|
-
u: "Underline",
|
|
1035
|
-
ul: "Unordered List",
|
|
1036
|
-
var: "Variable",
|
|
1037
|
-
video: "Video",
|
|
1038
|
-
wbr: "WBR"
|
|
1039
|
-
};
|
|
1040
|
-
const displayName = _PreciseType.FIXES_CASTABLE_TABLE[_PreciseType.normalizeKeyForCase(tagName)] ?? (DEFAULTS[tagName] ? `HTML ${DEFAULTS[tagName]} Element` : "HTML Element");
|
|
1041
|
-
return this.converter(displayName, { formatCase, useAcronyms });
|
|
1042
|
-
}
|
|
1043
|
-
/** @internal */
|
|
1044
|
-
getCommentNodeType(value, options) {
|
|
1045
|
-
const { formatCase, useAcronyms } = this.determineOptions(options);
|
|
1046
|
-
if (value instanceof Comment) {
|
|
1047
|
-
return this.converter(
|
|
1048
|
-
_PreciseType.FIXES_CASTABLE_TABLE[_PreciseType.normalizeKeyForCase("comment")] ?? "Comment",
|
|
1049
|
-
{ formatCase, useAcronyms }
|
|
1050
|
-
);
|
|
1051
|
-
}
|
|
1052
|
-
return null;
|
|
1053
|
-
}
|
|
1054
|
-
/** @internal */
|
|
1055
|
-
getTextNodeType(value, options) {
|
|
1056
|
-
const { formatCase, useAcronyms } = this.determineOptions(options);
|
|
1057
|
-
if (value instanceof Text) {
|
|
1058
|
-
return this.converter(
|
|
1059
|
-
_PreciseType.FIXES_CASTABLE_TABLE[_PreciseType.normalizeKeyForCase("text")] ?? "Text",
|
|
1060
|
-
{ formatCase, useAcronyms }
|
|
1061
|
-
);
|
|
1062
|
-
}
|
|
1063
|
-
return null;
|
|
1064
|
-
}
|
|
1065
|
-
/** @internal */
|
|
1066
|
-
getOtherNodeType(value, options) {
|
|
1067
|
-
const { formatCase, useAcronyms } = this.determineOptions(options);
|
|
1068
|
-
if (typeof Node !== "undefined" && value instanceof Node) {
|
|
1069
|
-
return this.converter(
|
|
1070
|
-
_PreciseType.FIXES_CASTABLE_TABLE[_PreciseType.normalizeKeyForCase("node")] ?? "Node",
|
|
1071
|
-
{ formatCase, useAcronyms }
|
|
1072
|
-
);
|
|
1073
|
-
}
|
|
1074
|
-
return null;
|
|
1075
|
-
}
|
|
1076
|
-
/** ----------------------------------------------------------
|
|
1077
|
-
* * ***Retrieves the canonical string representation of a given `Symbol`.***
|
|
1078
|
-
* ----------------------------------------------------------
|
|
1079
|
-
*
|
|
1080
|
-
* - **Description:**
|
|
1081
|
-
* - Converts a JavaScript `Symbol` (including well-known symbols) into a standardized,
|
|
1082
|
-
* human-readable name string.
|
|
1083
|
-
* - Maps **well-known symbols** (e.g., `Symbol.iterator`, `Symbol.asyncIterator`, `Symbol.toStringTag`)
|
|
1084
|
-
* to their corresponding normalized key in {@link PreciseType.castableTable | `castableTable`}.
|
|
1085
|
-
* - Supports formatted output according to the given `formatCase` and `useAcronyms` options.
|
|
1086
|
-
* - Falls back to the general `"Symbol"` type name if the provided symbol is not recognized.
|
|
1087
|
-
*
|
|
1088
|
-
* - **Example:**
|
|
1089
|
-
* ```ts
|
|
1090
|
-
* const precise = new PreciseType();
|
|
1091
|
-
*
|
|
1092
|
-
* precise.getSymbolName(Symbol.iterator);
|
|
1093
|
-
* // ➜ "symbol-iterator"
|
|
1094
|
-
*
|
|
1095
|
-
* precise.getSymbolName(Symbol.toStringTag, { formatCase: "toPascalCase" });
|
|
1096
|
-
* // ➜ "SymbolToStringTag"
|
|
1097
|
-
*
|
|
1098
|
-
* precise.getSymbolName(Symbol("custom"));
|
|
1099
|
-
* // ➜ "symbol"
|
|
1100
|
-
* ```
|
|
1101
|
-
*
|
|
1102
|
-
* - **Options:**
|
|
1103
|
-
* - `formatCase` → Determines the string case style for the resulting symbol name.
|
|
1104
|
-
* - `useAcronyms` → Preserves known acronyms (like `URL`, `DOM`, `HTML`) if set to `true`.
|
|
1105
|
-
*
|
|
1106
|
-
* - **⚠️ Internal:**
|
|
1107
|
-
* - Helper for {@link getPreciseType | `getPreciseType`} that normalizes `Symbol` detection.
|
|
1108
|
-
* - Not recommended for direct external use.
|
|
1109
|
-
*
|
|
1110
|
-
* @param value - The `Symbol` instance to analyze.
|
|
1111
|
-
* @param options - Optional settings for case formatting and acronym preservation.
|
|
1112
|
-
* @returns The formatted symbol name string.
|
|
1113
|
-
*
|
|
1114
|
-
* @internal
|
|
1115
|
-
*/
|
|
1116
|
-
getSymbolName(value, options) {
|
|
1117
|
-
const { formatCase, useAcronyms } = this.determineOptions(options);
|
|
1118
|
-
const symbolMap = /* @__PURE__ */ new Map([
|
|
1119
|
-
[Symbol.iterator, "symboliterator"],
|
|
1120
|
-
[Symbol.asyncIterator, "symbolasynciterator"],
|
|
1121
|
-
[Symbol.toStringTag, "symboltostringtag"],
|
|
1122
|
-
[Symbol.species, "symbolspecies"],
|
|
1123
|
-
[Symbol.hasInstance, "symbolhasinstance"],
|
|
1124
|
-
[Symbol.isConcatSpreadable, "symbolisconcatspreadable"],
|
|
1125
|
-
[Symbol.unscopables, "symbolunscopables"],
|
|
1126
|
-
[Symbol.match, "symbolmatch"],
|
|
1127
|
-
[Symbol.replace, "symbolreplace"],
|
|
1128
|
-
[Symbol.search, "symbolsearch"],
|
|
1129
|
-
[Symbol.split, "symbolsplit"],
|
|
1130
|
-
[Symbol.toPrimitive, "symboltoprimitive"],
|
|
1131
|
-
[Symbol.matchAll, "symbolmatchall"]
|
|
1132
|
-
]);
|
|
1133
|
-
const key = symbolMap.get(value);
|
|
1134
|
-
if (key) {
|
|
1135
|
-
return this.converter(
|
|
1136
|
-
_PreciseType.FIXES_CASTABLE_TABLE[_PreciseType.normalizeKeyForCase(key)] ?? key,
|
|
1137
|
-
{ formatCase, useAcronyms }
|
|
1138
|
-
);
|
|
1139
|
-
}
|
|
1140
|
-
return this.converter(
|
|
1141
|
-
_PreciseType.FIXES_CASTABLE_TABLE[_PreciseType.normalizeKeyForCase("symbol")] ?? "Symbol",
|
|
1142
|
-
{ formatCase, useAcronyms }
|
|
1143
|
-
);
|
|
1144
|
-
}
|
|
1145
|
-
/** ----------------------------------------------------------
|
|
1146
|
-
* * ***Detects the precise DOM node type of a given value.***
|
|
1147
|
-
* ----------------------------------------------------------
|
|
1148
|
-
*
|
|
1149
|
-
* - **Description:**
|
|
1150
|
-
* - Determines the specific **DOM Node subtype** (e.g., `HTMLDivElement`, `Comment`, `Text`, etc.)
|
|
1151
|
-
* based on the given input `value`.
|
|
1152
|
-
* - This method sequentially checks various DOM-related helpers:
|
|
1153
|
-
* - {@link PreciseType.getHtmlElementType | `getHtmlElementType`}
|
|
1154
|
-
* - {@link PreciseType.getCommentNodeType | `getCommentNodeType`}
|
|
1155
|
-
* - {@link PreciseType.getTextNodeType | `getTextNodeType`}
|
|
1156
|
-
* - {@link PreciseType.getOtherNodeType | `getOtherNodeType`}
|
|
1157
|
-
* - Returns the first non-null type result found.
|
|
1158
|
-
* - If no valid DOM node type is detected or an error occurs, it gracefully returns `null`.
|
|
1159
|
-
*
|
|
1160
|
-
* - **Example:**
|
|
1161
|
-
* ```ts
|
|
1162
|
-
* const detector = new PreciseType();
|
|
1163
|
-
* detector.detectDomNodeType(document.createElement("div"));
|
|
1164
|
-
* // ➜ "HTMLDivElement"
|
|
1165
|
-
*
|
|
1166
|
-
* detector.detectDomNodeType(document.createComment("test"));
|
|
1167
|
-
* // ➜ "Comment"
|
|
1168
|
-
*
|
|
1169
|
-
* detector.detectDomNodeType("not a node");
|
|
1170
|
-
* // ➜ null
|
|
1171
|
-
* ```
|
|
1172
|
-
*
|
|
1173
|
-
* - **Options:**
|
|
1174
|
-
* - `formatCase` → Controls the output formatting (e.g., `"toKebabCase"`, `"toPascalCase"`, etc.).
|
|
1175
|
-
* - `useAcronyms` → Determines if acronyms like `"HTML"` or `"SVG"` remain uppercase.
|
|
1176
|
-
*
|
|
1177
|
-
* - **⚠️ Internal:**
|
|
1178
|
-
* - Used internally by {@link getPreciseType | `getPreciseType`} to refine DOM-related type detection.
|
|
1179
|
-
* - Not intended for direct external use.
|
|
1180
|
-
*
|
|
1181
|
-
* @param value - The value to be inspected for a DOM node type.
|
|
1182
|
-
* @param options - Optional configuration to adjust case formatting and acronym behavior.
|
|
1183
|
-
* @returns The detected DOM node type string, or `null` if not applicable.
|
|
1184
|
-
*
|
|
1185
|
-
* @internal
|
|
1186
|
-
*/
|
|
1187
|
-
detectDomNodeType(value, options) {
|
|
1188
|
-
const { formatCase, useAcronyms } = this.determineOptions(options);
|
|
1189
|
-
try {
|
|
1190
|
-
return this.getHtmlElementType(value, { formatCase, useAcronyms }) || this.getCommentNodeType(value, { formatCase, useAcronyms }) || this.getTextNodeType(value, { formatCase, useAcronyms }) || this.getOtherNodeType(value, { formatCase, useAcronyms });
|
|
1191
|
-
} catch {
|
|
1192
|
-
return null;
|
|
1193
|
-
}
|
|
1194
|
-
}
|
|
1195
|
-
/** ----------------------------------------------------------
|
|
1196
|
-
* * ***Detects whether a given value is a Proxy instance.***
|
|
1197
|
-
* ----------------------------------------------------------
|
|
1198
|
-
*
|
|
1199
|
-
* - **Behavior:**
|
|
1200
|
-
* - Attempts to define and delete a temporary property to trigger potential Proxy traps.
|
|
1201
|
-
* - Works because most Proxy handlers will throw or behave differently during these operations.
|
|
1202
|
-
* - Transparent Proxies (without traps) will **not** be detected.
|
|
1203
|
-
*
|
|
1204
|
-
* @description
|
|
1205
|
-
* This method performs a heuristic check — it’s **not foolproof**, but reliably distinguishes
|
|
1206
|
-
* most Proxy-wrapped objects from ordinary ones without using non-standard APIs.
|
|
1207
|
-
*
|
|
1208
|
-
* @param value - The value to inspect.
|
|
1209
|
-
* @returns `true` if the value behaves like a Proxy (throws on property mutation),
|
|
1210
|
-
* otherwise `false`.
|
|
1211
|
-
*
|
|
1212
|
-
* @example
|
|
1213
|
-
* ```ts
|
|
1214
|
-
* const target = {};
|
|
1215
|
-
* const proxy = new Proxy(target, {});
|
|
1216
|
-
*
|
|
1217
|
-
* console.log(preciseType.isProxy(target)); // false
|
|
1218
|
-
* console.log(preciseType.isProxy(proxy)); // false (transparent proxy)
|
|
1219
|
-
*
|
|
1220
|
-
* const proxyWithTrap = new Proxy(target, {
|
|
1221
|
-
* set() { throw new Error("trap!"); }
|
|
1222
|
-
* });
|
|
1223
|
-
*
|
|
1224
|
-
* console.log(preciseType.isProxy(proxyWithTrap)); // true
|
|
1225
|
-
* ```
|
|
1226
|
-
*
|
|
1227
|
-
* @note
|
|
1228
|
-
* - Skips built-in native types (like `Array`, `Date`, `Map`, etc.) to prevent false positives.
|
|
1229
|
-
* - This is an **internal heuristic**, not a guaranteed Proxy detector.
|
|
1230
|
-
*
|
|
1231
|
-
* @internal
|
|
1232
|
-
*/
|
|
1233
|
-
isProxy(value) {
|
|
1234
|
-
if (isNull(value) || !isObjectOrArray(value)) return false;
|
|
1235
|
-
const tag = Object.prototype.toString.call(value);
|
|
1236
|
-
const skipTags = [
|
|
1237
|
-
"[object Array]",
|
|
1238
|
-
"[object Date]",
|
|
1239
|
-
"[object RegExp]",
|
|
1240
|
-
"[object Map]",
|
|
1241
|
-
"[object Set]",
|
|
1242
|
-
"[object WeakMap]",
|
|
1243
|
-
"[object WeakSet]",
|
|
1244
|
-
"[object Function]",
|
|
1245
|
-
"[object Error]",
|
|
1246
|
-
"[object Promise]",
|
|
1247
|
-
"[object Generator]",
|
|
1248
|
-
"[object GeneratorFunction]",
|
|
1249
|
-
"[object AsyncFunction]"
|
|
1250
|
-
];
|
|
1251
|
-
if (skipTags.includes(tag)) return false;
|
|
1252
|
-
try {
|
|
1253
|
-
Reflect.defineProperty(value, "__proxy_detect__", { configurable: true, value: 1 });
|
|
1254
|
-
Reflect.deleteProperty(value, "__proxy_detect__");
|
|
1255
|
-
return false;
|
|
1256
|
-
} catch {
|
|
1257
|
-
return true;
|
|
1258
|
-
}
|
|
1259
|
-
}
|
|
1260
|
-
/** ----------------------------------------------------------
|
|
1261
|
-
* * ***Helper function to convert an input string to a specific casing/format.***
|
|
1262
|
-
* ----------------------------------------------------------
|
|
1263
|
-
*
|
|
1264
|
-
* @description
|
|
1265
|
-
* - Chooses the conversion function based on the `formatCase` option.
|
|
1266
|
-
* - Supports multiple casing/formatting functions:
|
|
1267
|
-
* - `toPascalCaseSpace`.
|
|
1268
|
-
* - `toPascalCase`.
|
|
1269
|
-
* - `toCamelCase`.
|
|
1270
|
-
* - `toKebabCase`.
|
|
1271
|
-
* - `toSnakeCase`.
|
|
1272
|
-
* - `toDotCase`.
|
|
1273
|
-
* - `slugify`.
|
|
1274
|
-
* - Uses `ACRONYMS` as ignored words for certain conversion functions.
|
|
1275
|
-
*
|
|
1276
|
-
* @param {string} input - The string to convert.
|
|
1277
|
-
* @param {GetPreciseTypeOptions["formatCase"]} formatCase - The conversion method to apply.
|
|
1278
|
-
* @returns {string} The converted string according to the selected format.
|
|
1279
|
-
*
|
|
1280
|
-
* @example
|
|
1281
|
-
* converterHelper("hello world", "toCamelCase");
|
|
1282
|
-
* // ➔ "helloWorld"
|
|
1283
|
-
*
|
|
1284
|
-
* @example
|
|
1285
|
-
* converterHelper("my URL path", "slugify");
|
|
1286
|
-
* // ➔ "my-URL-path"
|
|
1287
|
-
*
|
|
1288
|
-
* @internal
|
|
1289
|
-
*/
|
|
1290
|
-
converter(input, options) {
|
|
1291
|
-
const { formatCase, useAcronyms } = this.determineOptions(options);
|
|
1292
|
-
const ignoreWord = useAcronyms ? _PreciseType.ACRONYMS : [];
|
|
1293
|
-
switch (formatCase) {
|
|
1294
|
-
case "slugify":
|
|
1295
|
-
return slugify(input, ignoreWord);
|
|
1296
|
-
case "toDotCase":
|
|
1297
|
-
return toDotCase(input, ignoreWord);
|
|
1298
|
-
case "toCamelCase":
|
|
1299
|
-
return toCamelCase(input, ignoreWord);
|
|
1300
|
-
case "toSnakeCase":
|
|
1301
|
-
return toSnakeCase(input, ignoreWord);
|
|
1302
|
-
case "toLowerCase":
|
|
1303
|
-
return toLowerCase(input, ignoreWord);
|
|
1304
|
-
case "toPascalCase":
|
|
1305
|
-
return toPascalCase(input, ignoreWord);
|
|
1306
|
-
case "toPascalCaseSpace":
|
|
1307
|
-
return toPascalCaseSpace(input, ignoreWord);
|
|
1308
|
-
default:
|
|
1309
|
-
return toKebabCase(input, ignoreWord);
|
|
1310
|
-
}
|
|
1311
|
-
}
|
|
1312
|
-
/** ----------------------------------------------------------
|
|
1313
|
-
* * ***Normalizes a string key for consistent case-insensitive matching.***
|
|
1314
|
-
* ----------------------------------------------------------
|
|
1315
|
-
*
|
|
1316
|
-
* - **Description:**
|
|
1317
|
-
* - This method removes all **spaces**, **underscores**, and **hyphens** from the given string,
|
|
1318
|
-
* then converts the result to **lowercase**.
|
|
1319
|
-
* - Used internally to ensure uniformity in key lookups and matching logic across
|
|
1320
|
-
* type mapping tables like {@link PreciseType.fixesRaw | `fixesRaw`} and
|
|
1321
|
-
* {@link PreciseType.castableTable | `castableTable`}.
|
|
1322
|
-
*
|
|
1323
|
-
* - **Example:**
|
|
1324
|
-
* ```ts
|
|
1325
|
-
* PreciseType.normalizeKeyForCase("Map.Type"); // ➔ "maptype"
|
|
1326
|
-
* PreciseType.normalizeKeyForCase("Map-Type"); // ➔ "maptype"
|
|
1327
|
-
* PreciseType.normalizeKeyForCase("Set Type"); // ➔ "settype"
|
|
1328
|
-
* PreciseType.normalizeKeyForCase("Array_Type"); // ➔ "arraytype"
|
|
1329
|
-
* ```
|
|
1330
|
-
*
|
|
1331
|
-
* - **⚠️ Internal:**
|
|
1332
|
-
* - Helper method used by {@link getPreciseType | `getPreciseType`} and internal mapping constants.
|
|
1333
|
-
* - Not intended for direct use in user code.
|
|
1334
|
-
*
|
|
1335
|
-
* @param k - The input string key to normalize.
|
|
1336
|
-
* @returns The normalized lowercase key with all separators removed.
|
|
1337
|
-
*
|
|
1338
|
-
* @internal
|
|
1339
|
-
*/
|
|
1340
|
-
static normalizeKeyForCase(k) {
|
|
1341
|
-
return k.replace(/[\s_\-\.]+/g, "").toLowerCase();
|
|
1342
|
-
}
|
|
1343
|
-
/** ----------------------------------------------------------
|
|
1344
|
-
* * ***Getting the internal map of type castable relationships used by {@link getPreciseType | `getPreciseType`}.***
|
|
1345
|
-
* ----------------------------------------------------------
|
|
1346
|
-
*
|
|
1347
|
-
* - **Description:**
|
|
1348
|
-
* - Returns an internal static mapping table that defines which primitive or structural types
|
|
1349
|
-
* can be cast or interpreted as another related type within the internal logic of
|
|
1350
|
-
* {@link getPreciseType | `getPreciseType`}.
|
|
1351
|
-
*
|
|
1352
|
-
* - **⚠️ Internal:**
|
|
1353
|
-
* - This is an internal helper of {@link getPreciseType | `getPreciseType`}.
|
|
1354
|
-
* - Do not modify or rely on this table directly — it is **readonly** and may change without notice.
|
|
1355
|
-
*
|
|
1356
|
-
* @readonly
|
|
1357
|
-
*/
|
|
1358
|
-
static get castableTable() {
|
|
1359
|
-
return _PreciseType.FIXES_CASTABLE_TABLE;
|
|
1360
|
-
}
|
|
1361
|
-
/** ----------------------------------------------------------
|
|
1362
|
-
* * ***Retrieves the internal list of special type cases handled by {@link getPreciseType | `getPreciseType`}.***
|
|
1363
|
-
* ----------------------------------------------------------
|
|
1364
|
-
*
|
|
1365
|
-
* - **Description:**
|
|
1366
|
-
* - Returns an internal readonly list of specific type identifiers that require
|
|
1367
|
-
* *custom handling* during type detection.
|
|
1368
|
-
* - These are **exceptional values** or **edge cases** that don’t follow the normal
|
|
1369
|
-
* JavaScript type resolution flow.
|
|
1370
|
-
*
|
|
1371
|
-
* - **Example Values:**
|
|
1372
|
-
* - `"Infinity"`, `"-Infinity"`, `"NaN"`, `"undefined"`, etc.
|
|
1373
|
-
*
|
|
1374
|
-
* - **⚠️ Internal:**
|
|
1375
|
-
* - Used internally by {@link getPreciseType | `getPreciseType`}.
|
|
1376
|
-
* - This property is **readonly** and should not be modified directly.
|
|
1377
|
-
*
|
|
1378
|
-
* @readonly
|
|
1379
|
-
*/
|
|
1380
|
-
static get specialType() {
|
|
1381
|
-
return this.SPECIAL_TYPE;
|
|
1382
|
-
}
|
|
1383
|
-
/** ----------------------------------------------------------
|
|
1384
|
-
* * ***Retrieves the internal mapping of JavaScript built-in and environment-specific
|
|
1385
|
-
* type identifiers to their canonical PascalCase names.***
|
|
1386
|
-
* ----------------------------------------------------------
|
|
1387
|
-
*
|
|
1388
|
-
* - **Description:**
|
|
1389
|
-
* - Provides a mapping table where **keys** represent normalized raw type names
|
|
1390
|
-
* (as obtained from `Object.prototype.toString.call(value)` or environment checks),
|
|
1391
|
-
* and **values** represent their **canonical PascalCase equivalents**.
|
|
1392
|
-
* - This table ensures consistent, human-readable type strings across different environments.
|
|
1393
|
-
*
|
|
1394
|
-
* - **Example Mapping:**
|
|
1395
|
-
* ```ts
|
|
1396
|
-
* {
|
|
1397
|
-
* "[object Map]": "Map",
|
|
1398
|
-
* "[object WeakMap]": "WeakMap",
|
|
1399
|
-
* "[object AsyncFunction]": "AsyncFunction",
|
|
1400
|
-
* "[object GeneratorFunction]": "GeneratorFunction",
|
|
1401
|
-
* "[object BigInt]": "BigInt",
|
|
1402
|
-
* }
|
|
1403
|
-
* ```
|
|
1404
|
-
*
|
|
1405
|
-
* - **⚠️ Internal:**
|
|
1406
|
-
* - Used internally by {@link getPreciseType | `getPreciseType`}.
|
|
1407
|
-
* - This property is **readonly** and should not be modified directly.
|
|
1408
|
-
*
|
|
1409
|
-
* @readonly
|
|
1410
|
-
*/
|
|
1411
|
-
static get fixesRaw() {
|
|
1412
|
-
return this.FIXES_RAW;
|
|
1413
|
-
}
|
|
1414
|
-
/** ----------------------------------------------------------
|
|
1415
|
-
* * ***Retrieves the internal list of common acronyms that should remain fully uppercase during string formatting.***
|
|
1416
|
-
* ----------------------------------------------------------
|
|
1417
|
-
*
|
|
1418
|
-
* - **Description:**
|
|
1419
|
-
* - This list defines acronyms (e.g., `"URL"`, `"HTTP"`, `"HTML"`, `"SVG"`, `"XML"`, `"DOM"`)
|
|
1420
|
-
* that will be **preserved in uppercase** when applying case transformations through
|
|
1421
|
-
* {@link getPreciseType | `getPreciseType`} or any formatting utility using it.
|
|
1422
|
-
* - Ensures consistency in output for technical identifiers that are conventionally capitalized.
|
|
1423
|
-
*
|
|
1424
|
-
* - **Example:**
|
|
1425
|
-
* ```ts
|
|
1426
|
-
* ["URL", "HTTP", "HTML", "SVG", "XML", "DOM"]
|
|
1427
|
-
* ```
|
|
1428
|
-
*
|
|
1429
|
-
* - **⚠️ Internal:**
|
|
1430
|
-
* - Used internally by {@link getPreciseType | `getPreciseType`}.
|
|
1431
|
-
* - This property is **readonly** and not intended for modification.
|
|
1432
|
-
*
|
|
1433
|
-
* @readonly
|
|
1434
|
-
*/
|
|
1435
|
-
static get acronymsList() {
|
|
1436
|
-
return this.ACRONYMS;
|
|
1437
|
-
}
|
|
1438
|
-
};
|
|
1439
|
-
|
|
1440
|
-
var getPreciseType = /* @__PURE__ */ (() => {
|
|
1441
|
-
const cache = /* @__PURE__ */ new Map();
|
|
1442
|
-
const MAX_CACHE_SIZE = 25;
|
|
1443
|
-
return (value, options = {}) => {
|
|
1444
|
-
if (!isPlainObject(options)) options = {};
|
|
1445
|
-
const key = JSON.stringify({
|
|
1446
|
-
formatCase: options.formatCase || "toKebabCase",
|
|
1447
|
-
useAcronyms: options.useAcronyms ?? false
|
|
1448
|
-
});
|
|
1449
|
-
let ClassPrecise = cache.get(key);
|
|
1450
|
-
if (!ClassPrecise) {
|
|
1451
|
-
if (cache.size >= MAX_CACHE_SIZE) cache.clear();
|
|
1452
|
-
ClassPrecise = new PreciseType(options);
|
|
1453
|
-
cache.set(key, ClassPrecise);
|
|
1454
|
-
}
|
|
1455
|
-
if (isNull(value)) {
|
|
1456
|
-
return ClassPrecise.converter(
|
|
1457
|
-
PreciseType.castableTable[PreciseType.normalizeKeyForCase("null")] ?? "Null"
|
|
1458
|
-
);
|
|
1459
|
-
}
|
|
1460
|
-
if (isNaN(value)) return "NaN";
|
|
1461
|
-
if (isInfinityNumber(value)) return String(value);
|
|
1462
|
-
if (typeof BigInt !== "undefined" && value === BigInt) {
|
|
1463
|
-
return ClassPrecise.converter(
|
|
1464
|
-
PreciseType.castableTable[PreciseType.normalizeKeyForCase("bigint constructor")]
|
|
1465
|
-
);
|
|
1466
|
-
}
|
|
1467
|
-
if (isNumberObject(value) || value === Number) {
|
|
1468
|
-
return ClassPrecise.converter(
|
|
1469
|
-
PreciseType.castableTable[PreciseType.normalizeKeyForCase("number constructor")]
|
|
1470
|
-
);
|
|
1471
|
-
}
|
|
1472
|
-
if (isStringObject(value) || value === String) {
|
|
1473
|
-
return ClassPrecise.converter(
|
|
1474
|
-
PreciseType.castableTable[PreciseType.normalizeKeyForCase("string constructor")]
|
|
1475
|
-
);
|
|
1476
|
-
}
|
|
1477
|
-
if (isBooleanObject(value) || value === Boolean) {
|
|
1478
|
-
return ClassPrecise.converter(
|
|
1479
|
-
PreciseType.castableTable[PreciseType.normalizeKeyForCase("boolean constructor")]
|
|
1480
|
-
);
|
|
1481
|
-
}
|
|
1482
|
-
const prim = typeof value;
|
|
1483
|
-
if (!isObjectOrArray(value) && !isFunction(value) && prim !== "symbol") {
|
|
1484
|
-
return ClassPrecise.converter(
|
|
1485
|
-
PreciseType.castableTable[PreciseType.normalizeKeyForCase(prim)] ?? prim
|
|
1486
|
-
);
|
|
1487
|
-
}
|
|
1488
|
-
if (prim === "symbol") {
|
|
1489
|
-
return ClassPrecise.getSymbolName(value);
|
|
1490
|
-
}
|
|
1491
|
-
if (isObjectOrArray(value) && value.constructor?.name === "EventEmitter") {
|
|
1492
|
-
return ClassPrecise.converter(
|
|
1493
|
-
PreciseType.castableTable[PreciseType.normalizeKeyForCase("event emitter")] ?? "Event Emitter"
|
|
1494
|
-
);
|
|
1495
|
-
}
|
|
1496
|
-
const domType = ClassPrecise.detectDomNodeType(value);
|
|
1497
|
-
if (domType) return domType;
|
|
1498
|
-
if (isBuffer(value)) {
|
|
1499
|
-
return ClassPrecise.converter(
|
|
1500
|
-
PreciseType.castableTable[PreciseType.normalizeKeyForCase("buffer")] ?? "Buffer"
|
|
1501
|
-
);
|
|
1502
|
-
}
|
|
1503
|
-
if (ClassPrecise.isProxy(value)) {
|
|
1504
|
-
return ClassPrecise.converter(
|
|
1505
|
-
PreciseType.castableTable[PreciseType.normalizeKeyForCase("proxy")] ?? "Proxy"
|
|
1506
|
-
);
|
|
1507
|
-
}
|
|
1508
|
-
if (isObject(value) && isFunction(value?.next) && isFunction(value?.throw)) {
|
|
1509
|
-
return ClassPrecise.converter(
|
|
1510
|
-
PreciseType.castableTable[PreciseType.normalizeKeyForCase("generator")] ?? "Generator"
|
|
1511
|
-
);
|
|
1512
|
-
}
|
|
1513
|
-
if (isError(value)) {
|
|
1514
|
-
const ctorName2 = value.constructor?.name ?? "Error";
|
|
1515
|
-
return ClassPrecise.converter(
|
|
1516
|
-
PreciseType.castableTable[PreciseType.normalizeKeyForCase(ctorName2)] ?? PreciseType.castableTable[PreciseType.normalizeKeyForCase(ctorName2.replace(/\s+/g, ""))] ?? ctorName2
|
|
1517
|
-
);
|
|
1518
|
-
}
|
|
1519
|
-
if (isObjectOrArray(value) && "done" in value && "value" in value && Object.keys(value).length === 2) {
|
|
1520
|
-
return ClassPrecise.converter(
|
|
1521
|
-
PreciseType.castableTable[PreciseType.normalizeKeyForCase("iterator result")]
|
|
1522
|
-
);
|
|
1523
|
-
}
|
|
1524
|
-
if (isNull(Object.getPrototypeOf(value))) {
|
|
1525
|
-
return ClassPrecise.converter(
|
|
1526
|
-
PreciseType.castableTable[PreciseType.normalizeKeyForCase("object")] ?? "Object"
|
|
1527
|
-
);
|
|
1528
|
-
}
|
|
1529
|
-
const tag = Object.prototype.toString.call(value).slice(8, -1) || "Object";
|
|
1530
|
-
const mapped = PreciseType.castableTable[PreciseType.normalizeKeyForCase(tag)];
|
|
1531
|
-
if (mapped) return ClassPrecise.converter(mapped);
|
|
1532
|
-
const ctorName = value?.constructor?.name;
|
|
1533
|
-
if (ctorName && ctorName !== "Object") {
|
|
1534
|
-
return ClassPrecise.converter(
|
|
1535
|
-
PreciseType.castableTable[PreciseType.normalizeKeyForCase(ctorName)] ?? ctorName
|
|
1536
|
-
);
|
|
1537
|
-
}
|
|
1538
|
-
return ClassPrecise.converter(tag);
|
|
1539
|
-
};
|
|
1540
|
-
})();
|
|
1541
|
-
|
|
1542
|
-
var determineErrorTypeAssertion = (type, message) => {
|
|
1543
|
-
switch (type) {
|
|
1544
|
-
case "Error":
|
|
1545
|
-
throw new Error(message);
|
|
1546
|
-
case "EvalError":
|
|
1547
|
-
throw new EvalError(message);
|
|
1548
|
-
case "RangeError":
|
|
1549
|
-
throw new RangeError(message);
|
|
1550
|
-
case "ReferenceError":
|
|
1551
|
-
throw new ReferenceError(message);
|
|
1552
|
-
case "SyntaxError":
|
|
1553
|
-
throw new SyntaxError(message);
|
|
1554
|
-
case "URIError":
|
|
1555
|
-
throw new URIError(message);
|
|
1556
|
-
case "TypeError":
|
|
1557
|
-
throw new TypeError(message);
|
|
1558
|
-
default:
|
|
1559
|
-
throw new TypeError(message);
|
|
1560
|
-
}
|
|
1561
|
-
};
|
|
1562
|
-
function resolveErrorMessageAssertions(params) {
|
|
1563
|
-
const { requiredValidType, value, options } = params || {};
|
|
1564
|
-
const {
|
|
1565
|
-
message,
|
|
1566
|
-
formatCase,
|
|
1567
|
-
useAcronyms,
|
|
1568
|
-
errorType = "TypeError"
|
|
1569
|
-
} = isPlainObject(options) ? options : {};
|
|
1570
|
-
const validType = toKebabCase(requiredValidType);
|
|
1571
|
-
const currentType = getPreciseType(value, { formatCase, useAcronyms });
|
|
1572
|
-
const messageFnOptions = { currentType, validType };
|
|
1573
|
-
const defaultMessage = `Parameter input (\`value\`) must be of type \`${validType}\`, but received: \`${currentType}\`.`;
|
|
1574
|
-
const errorMessage = isFunction(message) ? isNonEmptyString(message(messageFnOptions)) ? message(messageFnOptions).trim() : defaultMessage : isNonEmptyString(message) ? message.trim() : defaultMessage;
|
|
1575
|
-
return determineErrorTypeAssertion(errorType, errorMessage);
|
|
1576
|
-
}
|
|
1577
|
-
|
|
1578
|
-
function assertIsPlainObject(value, options = {}) {
|
|
1579
|
-
if (isPlainObject(value)) return;
|
|
1580
|
-
resolveErrorMessageAssertions({
|
|
1581
|
-
value,
|
|
1582
|
-
options,
|
|
1583
|
-
requiredValidType: "plain object"
|
|
1584
|
-
});
|
|
1585
|
-
}
|
|
1586
|
-
|
|
1587
|
-
export { assertIsBoolean, assertIsPlainObject, getPreciseType, hasOwnProp, isArray, isBoolean, isBooleanObject, isBuffer, isError, isFunction, isInfinityNumber, isNaN, isNil, isNonEmptyArray, isNonEmptyString, isNull, isNumber, isNumberObject, isObject, isObjectOrArray, isPlainObject, isSet, isString, isStringObject, isSymbol, isUndefined, resolveErrorMessageAssertions, slugify, toCamelCase, toDotCase, toKebabCase, toLowerCase, toPascalCase, toPascalCaseSpace, toSnakeCase };
|