@rzl-zone/utils-js 3.13.1 → 3.14.0-beta.0
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/README.md +7 -6
- package/dist/.references/index.d.cts +2 -1
- package/dist/.references/index.d.ts +2 -1
- package/dist/AbortError-DK6kpzbu.cjs +26 -0
- package/dist/AbortError-DK6kpzbu.cjs.map +1 -0
- package/dist/AbortError-DVT8lAKn.js +20 -0
- package/dist/AbortError-DVT8lAKn.js.map +1 -0
- package/dist/{assertIsArray-HgzPQIAM.js → assertIsArray-CG7L7vlt.js} +3 -3
- package/dist/assertIsArray-CG7L7vlt.js.map +1 -0
- package/dist/{assertIsArray-CeXL4xv5.cjs → assertIsArray-CtCRD-_G.cjs} +5 -5
- package/dist/assertIsArray-CtCRD-_G.cjs.map +1 -0
- package/dist/assertIsPlainObject-DPZLj-Ho.cjs +26 -0
- package/dist/assertIsPlainObject-DPZLj-Ho.cjs.map +1 -0
- package/dist/assertIsPlainObject-j9bDqNLo.js +20 -0
- package/dist/assertIsPlainObject-j9bDqNLo.js.map +1 -0
- package/dist/{assertIsString-CY_WkCLr.js → assertIsString-CHIwE12y.js} +4 -4
- package/dist/assertIsString-CHIwE12y.js.map +1 -0
- package/dist/{assertIsString-DUrVt82d.cjs → assertIsString-CjE9kbQ_.cjs} +6 -6
- package/dist/assertIsString-CjE9kbQ_.cjs.map +1 -0
- package/dist/assertions/index.cjs +14 -12
- package/dist/assertions/index.cjs.map +1 -1
- package/dist/assertions/index.d.cts +2 -2
- package/dist/assertions/index.d.ts +2 -2
- package/dist/assertions/index.js +10 -8
- package/dist/assertions/index.js.map +1 -1
- package/dist/conversions/index.cjs +6 -6
- package/dist/conversions/index.d.cts +2 -2
- package/dist/conversions/index.d.ts +2 -2
- package/dist/conversions/index.js +6 -6
- package/dist/conversions-BFz6MKaV.cjs +449 -0
- package/dist/conversions-BFz6MKaV.cjs.map +1 -0
- package/dist/{conversions-1s7xMBe_.js → conversions-Ben5p5Ts.js} +43 -40
- package/dist/conversions-Ben5p5Ts.js.map +1 -0
- package/dist/errors/index.cjs +13 -0
- package/dist/errors/index.d.cts +180 -0
- package/dist/errors/index.d.ts +180 -0
- package/dist/errors/index.js +11 -0
- package/dist/events/index.cjs +10 -9
- package/dist/events/index.cjs.map +1 -1
- package/dist/events/index.d.cts +185 -100
- package/dist/events/index.d.ts +185 -100
- package/dist/events/index.js +9 -8
- package/dist/events/index.js.map +1 -1
- package/dist/formatter-ekJQF_bA-BepnCBkQ.cjs +67 -0
- package/dist/formatter-ekJQF_bA-BepnCBkQ.cjs.map +1 -0
- package/dist/formatter-ekJQF_bA-xLD9mGk4.js +55 -0
- package/dist/formatter-ekJQF_bA-xLD9mGk4.js.map +1 -0
- package/dist/formatters/index.cjs +2 -2
- package/dist/formatters/index.d.cts +2 -2
- package/dist/formatters/index.d.ts +2 -2
- package/dist/formatters/index.js +2 -2
- package/dist/{formatters-C6cVZBbG.js → formatters-BAbGsnYA.js} +78 -71
- package/dist/formatters-BAbGsnYA.js.map +1 -0
- package/dist/formatters-zd0Gs4Cs.cjs +436 -0
- package/dist/formatters-zd0Gs4Cs.cjs.map +1 -0
- package/dist/generators/index.cjs +37 -31
- package/dist/generators/index.cjs.map +1 -1
- package/dist/generators/index.d.cts +2 -2
- package/dist/generators/index.d.ts +2 -2
- package/dist/generators/index.js +29 -23
- package/dist/generators/index.js.map +1 -1
- package/dist/hasOwnProp-CVIhlD1i.js +47 -0
- package/dist/hasOwnProp-CVIhlD1i.js.map +1 -0
- package/dist/hasOwnProp-D9Tpgokd.cjs +53 -0
- package/dist/hasOwnProp-D9Tpgokd.cjs.map +1 -0
- package/dist/{index-RNQBTK8A.d.cts → index-9JsU_wMu.d.ts} +1375 -937
- package/dist/{index-ORbo-7zA.d.cts → index-BP3sUrAx.d.ts} +242 -133
- package/dist/{index-BG8wdusZ.d.cts → index-BVovC-yK.d.cts} +229 -200
- package/dist/index-C1X6ha9s.d.cts +1041 -0
- package/dist/index-CcPQZ41G.d.cts +1103 -0
- package/dist/index-CjpbuJF4.d.ts +2424 -0
- package/dist/index-CssrQyHh.d.cts +2424 -0
- package/dist/index-DZHiYYR7.d.cts +2179 -0
- package/dist/index-DZHiYYR7.d.ts +2179 -0
- package/dist/index-DlyDmXUo.d.ts +1103 -0
- package/dist/index-Dm4a___O.d.ts +1041 -0
- package/dist/{index-CRz9rSZL.d.ts → index-Dwduk7ez.d.cts} +1375 -937
- package/dist/{index-DPJ-e2JZ.d.ts → index-I5V6RbZM.d.cts} +1592 -790
- package/dist/{index-B5EBAgmC.d.cts → index-hOqBIL7F.d.ts} +1592 -790
- package/dist/{index-B1VQ6USF.d.ts → index-jyuOZMX7.d.ts} +229 -200
- package/dist/{index-ORbo-7zA.d.ts → index-lI0b7iUz.d.cts} +242 -133
- package/dist/{isBigInt-y7s3rsKc.js → isBigInt-Cez32M69.js} +2 -2
- package/dist/isBigInt-Cez32M69.js.map +1 -0
- package/dist/{isBigInt-BVj0M5pq.cjs → isBigInt-YgpNKTbA.cjs} +2 -2
- package/dist/isBigInt-YgpNKTbA.cjs.map +1 -0
- package/dist/{isEmptyString-BYMz_wt9.js → isEmptyString-C9QLWjx2.js} +4 -4
- package/dist/isEmptyString-C9QLWjx2.js.map +1 -0
- package/dist/{isEmptyString-C8PYNPgw.cjs → isEmptyString-O4TFe1Ao.cjs} +5 -5
- package/dist/isEmptyString-O4TFe1Ao.cjs.map +1 -0
- package/dist/isEmptyValue-CFExALXZ.cjs +54 -0
- package/dist/isEmptyValue-CFExALXZ.cjs.map +1 -0
- package/dist/isEmptyValue-kCjnLjbN.js +36 -0
- package/dist/isEmptyValue-kCjnLjbN.js.map +1 -0
- package/dist/{isFinite-DeDaBDr2.cjs → isFinite-B_hHbDpa.cjs} +6 -6
- package/dist/isFinite-B_hHbDpa.cjs.map +1 -0
- package/dist/{isFinite-BEJFOv6B.js → isFinite-ZvNhyHlF.js} +5 -5
- package/dist/isFinite-ZvNhyHlF.js.map +1 -0
- package/dist/{isInteger-DEDbBGez.js → isInteger-aZgzTTZG.js} +4 -4
- package/dist/isInteger-aZgzTTZG.js.map +1 -0
- package/dist/{isInteger-CQLThJOR.cjs → isInteger-dnc6W63Z.cjs} +4 -4
- package/dist/isInteger-dnc6W63Z.cjs.map +1 -0
- package/dist/isNumber-BCWD4dW0.js +20 -0
- package/dist/isNumber-BCWD4dW0.js.map +1 -0
- package/dist/isNumber-BkzwAe50.cjs +26 -0
- package/dist/isNumber-BkzwAe50.cjs.map +1 -0
- package/dist/isPlainObject-CAe_ElKO.d.cts +331 -0
- package/dist/isPlainObject-CJvRG4Je.d.ts +331 -0
- package/dist/{isServer-q3o6cSwD.js → isServer-CQzrX5e0.js} +2 -2
- package/dist/isServer-CQzrX5e0.js.map +1 -0
- package/dist/{isServer-DmycqWsF.cjs → isServer-DhFaedeT.cjs} +2 -2
- package/dist/isServer-DhFaedeT.cjs.map +1 -0
- package/dist/{isEqual-DaPDxMyw.cjs → isTypedArray-DjADSu8q.cjs} +45 -13
- package/dist/isTypedArray-DjADSu8q.cjs.map +1 -0
- package/dist/{isEqual-DM4S_kWh.js → isTypedArray-DxsPKrLh.js} +29 -9
- package/dist/isTypedArray-DxsPKrLh.js.map +1 -0
- package/dist/{isValidDomain-B8Nukgw0.js → isValidDomain-CDtNOhMc.js} +13 -54
- package/dist/isValidDomain-CDtNOhMc.js.map +1 -0
- package/dist/{isValidDomain-ZbyeGOO9.cjs → isValidDomain-D_x7uNIu.cjs} +16 -69
- package/dist/isValidDomain-D_x7uNIu.cjs.map +1 -0
- package/dist/{assertIsBoolean-CWUs-I5l.js → logger-CLWnKRKE.js} +657 -587
- package/dist/logger-CLWnKRKE.js.map +1 -0
- package/dist/{assertIsBoolean-D41HrTB_.cjs → logger-CUacYy3D.cjs} +658 -612
- package/dist/logger-CUacYy3D.cjs.map +1 -0
- package/dist/{noop-BY43WaoU.cjs → noop-CjEbNsJL.cjs} +2 -2
- package/dist/noop-CjEbNsJL.cjs.map +1 -0
- package/dist/{noop-CjY8xVHv.js → noop-qxrcogt5.js} +2 -2
- package/dist/noop-qxrcogt5.js.map +1 -0
- package/dist/{normalizeSpaces-BhZp0U_6.cjs → normalizeSpaces-D0_Z4qnO.cjs} +6 -9
- package/dist/normalizeSpaces-D0_Z4qnO.cjs.map +1 -0
- package/dist/{normalizeSpaces-BoUDtq5P.js → normalizeSpaces-DAsxzBEQ.js} +4 -7
- package/dist/normalizeSpaces-DAsxzBEQ.js.map +1 -0
- package/dist/operations/index.cjs +152 -22
- package/dist/operations/index.cjs.map +1 -1
- package/dist/operations/index.d.cts +257 -35
- package/dist/operations/index.d.ts +257 -35
- package/dist/operations/index.js +142 -13
- package/dist/operations/index.js.map +1 -1
- package/dist/parsers/index.cjs +2 -2
- package/dist/parsers/index.d.cts +238 -180
- package/dist/parsers/index.d.ts +238 -180
- package/dist/parsers/index.js +2 -2
- package/dist/{parsers-B8KYXIjE.js → parsers-BBAE_xVM.js} +9 -8
- package/dist/parsers-BBAE_xVM.js.map +1 -0
- package/dist/{parsers-B_FPX35n.cjs → parsers-i8WEeMJl.cjs} +10 -9
- package/dist/parsers-i8WEeMJl.cjs.map +1 -0
- package/dist/{parsing-Bfaw85Hd.js → parsing-D9tbKQ0v.js} +3 -3
- package/dist/parsing-D9tbKQ0v.js.map +1 -0
- package/dist/{parsing-BCZGco7n.cjs → parsing-DGjB8cwr.cjs} +4 -4
- package/dist/parsing-DGjB8cwr.cjs.map +1 -0
- package/dist/predicates/index.cjs +43 -43
- package/dist/predicates/index.d.cts +3 -3
- package/dist/predicates/index.d.ts +3 -3
- package/dist/predicates/index.js +14 -14
- package/dist/{predicates-KlyOvBSC.js → predicates-C0dova7l.js} +45 -40
- package/dist/predicates-C0dova7l.js.map +1 -0
- package/dist/{predicates-8y28VrbT.cjs → predicates-Dd7To7B4.cjs} +89 -84
- package/dist/predicates-Dd7To7B4.cjs.map +1 -0
- package/dist/promises/index.cjs +27 -26
- package/dist/promises/index.cjs.map +1 -1
- package/dist/promises/index.d.cts +227 -75
- package/dist/promises/index.d.ts +227 -75
- package/dist/promises/index.js +27 -26
- package/dist/promises/index.js.map +1 -1
- package/dist/{punyCode-DnKi0qjS.cjs → punyCode-DHTLhGdD.cjs} +12 -12
- package/dist/punyCode-DHTLhGdD.cjs.map +1 -0
- package/dist/{punyCode-Dwto1RpA.js → punyCode-Deb1Mrkc.js} +12 -12
- package/dist/punyCode-Deb1Mrkc.js.map +1 -0
- package/dist/{removeSpaces--8NW-HSx.js → removeSpaces-BPnsdRN0.js} +4 -4
- package/dist/removeSpaces-BPnsdRN0.js.map +1 -0
- package/dist/{removeSpaces-CmrrkeXz.cjs → removeSpaces-CN3pxBz_.cjs} +7 -7
- package/dist/removeSpaces-CN3pxBz_.cjs.map +1 -0
- package/dist/rzl-utils.global.js +13 -13
- package/dist/safeJsonParse-D1FLVTEM.cjs +209 -0
- package/dist/safeJsonParse-D1FLVTEM.cjs.map +1 -0
- package/dist/{safeJsonParse-OnUwG2El.js → safeJsonParse-DEVKNDSn.js} +29 -28
- package/dist/safeJsonParse-DEVKNDSn.js.map +1 -0
- package/dist/safeStableStringify-C5HHKUdn.cjs +125 -0
- package/dist/safeStableStringify-C5HHKUdn.cjs.map +1 -0
- package/dist/{safeStableStringify-B2KTTS3r.js → safeStableStringify-DfwxmiWn.js} +20 -13
- package/dist/safeStableStringify-DfwxmiWn.js.map +1 -0
- package/dist/strings/index.cjs +26 -30
- package/dist/strings/index.cjs.map +1 -1
- package/dist/strings/index.d.cts +2 -2
- package/dist/strings/index.d.ts +2 -2
- package/dist/strings/index.js +13 -17
- package/dist/strings/index.js.map +1 -1
- package/dist/tailwind/index.cjs +3 -3
- package/dist/tailwind/index.d.cts +3 -3
- package/dist/tailwind/index.d.ts +3 -3
- package/dist/tailwind/index.js +3 -3
- package/dist/{tailwind-DUuboq52.cjs → tailwind-BG7B0cDs.cjs} +59 -53
- package/dist/tailwind-BG7B0cDs.cjs.map +1 -0
- package/dist/{tailwind-CUdmv-oO.js → tailwind-tJNnFPsF.js} +38 -32
- package/dist/tailwind-tJNnFPsF.js.map +1 -0
- package/dist/{toStringArrayUnRecursive-OOHGazks.js → toStringArrayUnRecursive-D0WbLIRz.js} +9 -9
- package/dist/toStringArrayUnRecursive-D0WbLIRz.js.map +1 -0
- package/dist/toStringArrayUnRecursive-QLoaNX_-.cjs +51 -0
- package/dist/toStringArrayUnRecursive-QLoaNX_-.cjs.map +1 -0
- package/dist/urls/index.cjs +3 -3
- package/dist/urls/index.d.cts +635 -443
- package/dist/urls/index.d.ts +635 -443
- package/dist/urls/index.js +3 -3
- package/dist/{urls-BXT4Krsq.js → urls-EoWslGgg.js} +50 -41
- package/dist/urls-EoWslGgg.js.map +1 -0
- package/dist/urls-NCzPepe2.cjs +308 -0
- package/dist/urls-NCzPepe2.cjs.map +1 -0
- package/package.json +6 -6
- package/dist/assertIsArray-CeXL4xv5.cjs.map +0 -1
- package/dist/assertIsArray-HgzPQIAM.js.map +0 -1
- package/dist/assertIsBoolean-CWUs-I5l.js.map +0 -1
- package/dist/assertIsBoolean-D41HrTB_.cjs.map +0 -1
- package/dist/assertIsString-CY_WkCLr.js.map +0 -1
- package/dist/assertIsString-DUrVt82d.cjs.map +0 -1
- package/dist/conversions-1s7xMBe_.js.map +0 -1
- package/dist/conversions-B3Rf8uId.cjs +0 -446
- package/dist/conversions-B3Rf8uId.cjs.map +0 -1
- package/dist/formatters-C6cVZBbG.js.map +0 -1
- package/dist/formatters-aEAAuzjx.cjs +0 -429
- package/dist/formatters-aEAAuzjx.cjs.map +0 -1
- package/dist/index-CPCt6_Wq.d.cts +0 -765
- package/dist/index-CPCt6_Wq.d.ts +0 -765
- package/dist/index-DBwNa1iO.d.ts +0 -947
- package/dist/index-DPTYOQkn.d.cts +0 -947
- package/dist/index-Dig1fIhZ.d.cts +0 -1716
- package/dist/index-Dig1fIhZ.d.ts +0 -1716
- package/dist/isBigInt-BVj0M5pq.cjs.map +0 -1
- package/dist/isBigInt-y7s3rsKc.js.map +0 -1
- package/dist/isEmptyObject-BsHngDz4.cjs +0 -37
- package/dist/isEmptyObject-BsHngDz4.cjs.map +0 -1
- package/dist/isEmptyObject-DPGR9iPj.js +0 -25
- package/dist/isEmptyObject-DPGR9iPj.js.map +0 -1
- package/dist/isEmptyString-BYMz_wt9.js.map +0 -1
- package/dist/isEmptyString-C8PYNPgw.cjs.map +0 -1
- package/dist/isEmptyValue-BXf7f1jz.cjs +0 -30
- package/dist/isEmptyValue-BXf7f1jz.cjs.map +0 -1
- package/dist/isEmptyValue-D4OHTB3u.js +0 -24
- package/dist/isEmptyValue-D4OHTB3u.js.map +0 -1
- package/dist/isEqual-DM4S_kWh.js.map +0 -1
- package/dist/isEqual-DaPDxMyw.cjs.map +0 -1
- package/dist/isFinite-BEJFOv6B.js.map +0 -1
- package/dist/isFinite-DeDaBDr2.cjs.map +0 -1
- package/dist/isInteger-CQLThJOR.cjs.map +0 -1
- package/dist/isInteger-DEDbBGez.js.map +0 -1
- package/dist/isPlainObject-BwTkj3G0.d.cts +0 -339
- package/dist/isPlainObject-BwTkj3G0.d.ts +0 -339
- package/dist/isServer-DmycqWsF.cjs.map +0 -1
- package/dist/isServer-q3o6cSwD.js.map +0 -1
- package/dist/isTypedArray-BQLbLXsU.cjs +0 -43
- package/dist/isTypedArray-BQLbLXsU.cjs.map +0 -1
- package/dist/isTypedArray-XiBnifLN.js +0 -31
- package/dist/isTypedArray-XiBnifLN.js.map +0 -1
- package/dist/isValidDomain-B8Nukgw0.js.map +0 -1
- package/dist/isValidDomain-ZbyeGOO9.cjs.map +0 -1
- package/dist/noop-BY43WaoU.cjs.map +0 -1
- package/dist/noop-CjY8xVHv.js.map +0 -1
- package/dist/normalizeSpaces-BhZp0U_6.cjs.map +0 -1
- package/dist/normalizeSpaces-BoUDtq5P.js.map +0 -1
- package/dist/parsers-B8KYXIjE.js.map +0 -1
- package/dist/parsers-B_FPX35n.cjs.map +0 -1
- package/dist/parsing-BCZGco7n.cjs.map +0 -1
- package/dist/parsing-Bfaw85Hd.js.map +0 -1
- package/dist/predicates-8y28VrbT.cjs.map +0 -1
- package/dist/predicates-KlyOvBSC.js.map +0 -1
- package/dist/punyCode-DnKi0qjS.cjs.map +0 -1
- package/dist/punyCode-Dwto1RpA.js.map +0 -1
- package/dist/removeSpaces--8NW-HSx.js.map +0 -1
- package/dist/removeSpaces-CmrrkeXz.cjs.map +0 -1
- package/dist/safeJsonParse-OnUwG2El.js.map +0 -1
- package/dist/safeJsonParse-sFqVXf-e.cjs +0 -208
- package/dist/safeJsonParse-sFqVXf-e.cjs.map +0 -1
- package/dist/safeStableStringify-B2KTTS3r.js.map +0 -1
- package/dist/safeStableStringify-Cmi6GyWj.cjs +0 -106
- package/dist/safeStableStringify-Cmi6GyWj.cjs.map +0 -1
- package/dist/tailwind-CUdmv-oO.js.map +0 -1
- package/dist/tailwind-DUuboq52.cjs.map +0 -1
- package/dist/toStringArrayUnRecursive-OOHGazks.js.map +0 -1
- package/dist/toStringArrayUnRecursive-pfk2oP8C.cjs +0 -51
- package/dist/toStringArrayUnRecursive-pfk2oP8C.cjs.map +0 -1
- package/dist/urls-BL9C_yU3.cjs +0 -299
- package/dist/urls-BL9C_yU3.cjs.map +0 -1
- package/dist/urls-BXT4Krsq.js.map +0 -1
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* ========================================================================
|
|
3
3
|
* @rzl-zone/utils-js
|
|
4
4
|
* ------------------------------------------------------------------------
|
|
5
|
-
* Version: `3.
|
|
5
|
+
* Version: `3.14.0-beta.0`
|
|
6
6
|
* Author: `Rizalvin Dwiky <rizalvindwiky@gmail.com>`
|
|
7
7
|
* Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/utils-js`
|
|
8
8
|
* ========================================================================
|
|
@@ -11,4 +11,4 @@ const isServer = () => {
|
|
|
11
11
|
return typeof window === "undefined" || typeof document === "undefined";
|
|
12
12
|
};
|
|
13
13
|
export { isServer as t };
|
|
14
|
-
//# sourceMappingURL=isServer-
|
|
14
|
+
//# sourceMappingURL=isServer-CQzrX5e0.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isServer-CQzrX5e0.js","names":[],"sources":["../src/predicates/is/isServer.ts"],"sourcesContent":["/** ---------------------------------------------------------\n * * ***Environment Predicate: `isServer`.***\n * ----------------------------------------------------------\n * **Detects whether the current code is executing in a\n * **non-browser JavaScript runtime** (server-side) rather\n * than in a web browser.**\n *\n * ---\n * @description\n * It simply checks for the absence of key browser globals like\n * [**`window`**](https://developer.mozilla.org/docs/Web/API/Window/window) and\n * [**`document`**](https://developer.mozilla.org/docs/Web/API/Window/document).\n * - *If those globals aren’t present, we treat the runtime as a server environment.*\n *\n * ---\n * @returns {boolean}\n * * ***true** – Code is executing on the `server`.*\n * * ***false** – Code is executing in a `browser`.*\n *\n * ---\n * @example\n * if (isServer()) {\n * console.log(\"Running on a server-side runtime\");\n * } else {\n * console.log(\"Running in a browser\");\n * }\n */\nexport const isServer = (): boolean => {\n return typeof window === \"undefined\" || typeof document === \"undefined\";\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,MAAa,iBAA0B;CACrC,OAAO,OAAO,WAAW,eAAe,OAAO,aAAa;AAC9D"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* ========================================================================
|
|
3
3
|
* @rzl-zone/utils-js
|
|
4
4
|
* ------------------------------------------------------------------------
|
|
5
|
-
* Version: `3.
|
|
5
|
+
* Version: `3.14.0-beta.0`
|
|
6
6
|
* Author: `Rizalvin Dwiky <rizalvindwiky@gmail.com>`
|
|
7
7
|
* Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/utils-js`
|
|
8
8
|
* ========================================================================
|
|
@@ -17,4 +17,4 @@ Object.defineProperty(exports, 'isServer', {
|
|
|
17
17
|
return isServer;
|
|
18
18
|
}
|
|
19
19
|
});
|
|
20
|
-
//# sourceMappingURL=isServer-
|
|
20
|
+
//# sourceMappingURL=isServer-DhFaedeT.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isServer-DhFaedeT.cjs","names":[],"sources":["../src/predicates/is/isServer.ts"],"sourcesContent":["/** ---------------------------------------------------------\n * * ***Environment Predicate: `isServer`.***\n * ----------------------------------------------------------\n * **Detects whether the current code is executing in a\n * **non-browser JavaScript runtime** (server-side) rather\n * than in a web browser.**\n *\n * ---\n * @description\n * It simply checks for the absence of key browser globals like\n * [**`window`**](https://developer.mozilla.org/docs/Web/API/Window/window) and\n * [**`document`**](https://developer.mozilla.org/docs/Web/API/Window/document).\n * - *If those globals aren’t present, we treat the runtime as a server environment.*\n *\n * ---\n * @returns {boolean}\n * * ***true** – Code is executing on the `server`.*\n * * ***false** – Code is executing in a `browser`.*\n *\n * ---\n * @example\n * if (isServer()) {\n * console.log(\"Running on a server-side runtime\");\n * } else {\n * console.log(\"Running in a browser\");\n * }\n */\nexport const isServer = (): boolean => {\n return typeof window === \"undefined\" || typeof document === \"undefined\";\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,MAAa,iBAA0B;CACrC,OAAO,OAAO,WAAW,eAAe,OAAO,aAAa;AAC9D"}
|
|
@@ -2,36 +2,37 @@
|
|
|
2
2
|
* ========================================================================
|
|
3
3
|
* @rzl-zone/utils-js
|
|
4
4
|
* ------------------------------------------------------------------------
|
|
5
|
-
* Version: `3.
|
|
5
|
+
* Version: `3.14.0-beta.0`
|
|
6
6
|
* Author: `Rizalvin Dwiky <rizalvindwiky@gmail.com>`
|
|
7
7
|
* Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/utils-js`
|
|
8
8
|
* ========================================================================
|
|
9
9
|
*/
|
|
10
10
|
"use strict";
|
|
11
|
-
const
|
|
12
|
-
const
|
|
11
|
+
const require_logger = require('./logger-CUacYy3D.cjs');
|
|
12
|
+
const require_isEmptyValue = require('./isEmptyValue-CFExALXZ.cjs');
|
|
13
|
+
const require_safeStableStringify = require('./safeStableStringify-C5HHKUdn.cjs');
|
|
13
14
|
const isRegExp = (value) => {
|
|
14
15
|
return value instanceof RegExp;
|
|
15
16
|
};
|
|
16
|
-
|
|
17
|
+
const isArrayBuffer = (value) => {
|
|
17
18
|
return value instanceof ArrayBuffer;
|
|
18
|
-
}
|
|
19
|
+
};
|
|
19
20
|
function baseDeepEqual(value, other, customizer, seen = /* @__PURE__ */ new WeakMap()) {
|
|
20
21
|
if (value === other) return true;
|
|
21
22
|
if (value !== value && other !== other) return true;
|
|
22
|
-
if (!
|
|
23
|
+
if (!require_logger.isObjectOrArray(value) || !require_logger.isObjectOrArray(other)) return false;
|
|
23
24
|
if (seen.get(value) === other) return true;
|
|
24
25
|
seen.set(value, other);
|
|
25
26
|
const callCustomizer = (v, o, key, valObj, othObj) => {
|
|
26
27
|
if (customizer) {
|
|
27
28
|
const result = customizer(v, o, key, valObj, othObj, seen);
|
|
28
|
-
if (!
|
|
29
|
+
if (!require_safeStableStringify.isUndefined(result)) return result;
|
|
29
30
|
}
|
|
30
31
|
return baseDeepEqual(v, o, customizer, seen);
|
|
31
32
|
};
|
|
32
33
|
if (require_safeStableStringify.isDate(value) && require_safeStableStringify.isDate(other)) return value.getTime() === other.getTime();
|
|
33
34
|
if (isRegExp(value) && isRegExp(other)) return value.source === other.source && value.flags === other.flags;
|
|
34
|
-
if (
|
|
35
|
+
if (require_logger.isError(value) && require_logger.isError(other)) return value.name === other.name && value.message === other.message;
|
|
35
36
|
if (ArrayBuffer.isView(value) && ArrayBuffer.isView(other)) {
|
|
36
37
|
const v = new Uint8Array(value.buffer, value.byteOffset, value.byteLength);
|
|
37
38
|
const o = new Uint8Array(other.buffer, other.byteOffset, other.byteLength);
|
|
@@ -53,7 +54,7 @@ function baseDeepEqual(value, other, customizer, seen = /* @__PURE__ */ new Weak
|
|
|
53
54
|
}
|
|
54
55
|
return true;
|
|
55
56
|
}
|
|
56
|
-
if (
|
|
57
|
+
if (require_logger.isSet(value) && require_logger.isSet(other)) {
|
|
57
58
|
if (value.size !== other.size) return false;
|
|
58
59
|
for (const v of value) {
|
|
59
60
|
let matched = false;
|
|
@@ -65,7 +66,7 @@ function baseDeepEqual(value, other, customizer, seen = /* @__PURE__ */ new Weak
|
|
|
65
66
|
}
|
|
66
67
|
return true;
|
|
67
68
|
}
|
|
68
|
-
if (
|
|
69
|
+
if (require_logger.isArray(value) && require_logger.isArray(other)) {
|
|
69
70
|
if (value.length !== other.length) return false;
|
|
70
71
|
for (let i = 0; i < value.length; i++) if (!callCustomizer(value[i], other[i], i, value, other)) return false;
|
|
71
72
|
return true;
|
|
@@ -81,9 +82,28 @@ function baseDeepEqual(value, other, customizer, seen = /* @__PURE__ */ new Weak
|
|
|
81
82
|
}
|
|
82
83
|
return true;
|
|
83
84
|
}
|
|
84
|
-
|
|
85
|
+
const isEqual = (value, other) => {
|
|
85
86
|
return baseDeepEqual(value, other, void 0, /* @__PURE__ */ new WeakMap());
|
|
86
|
-
}
|
|
87
|
+
};
|
|
88
|
+
const isNonEmptyValue = (value, options = {}) => {
|
|
89
|
+
return !require_isEmptyValue.isEmptyValue(value, options);
|
|
90
|
+
};
|
|
91
|
+
const typedArrayTags = new Set([
|
|
92
|
+
"[object Int8Array]",
|
|
93
|
+
"[object Uint8Array]",
|
|
94
|
+
"[object Uint8ClampedArray]",
|
|
95
|
+
"[object Int16Array]",
|
|
96
|
+
"[object Uint16Array]",
|
|
97
|
+
"[object Int32Array]",
|
|
98
|
+
"[object Uint32Array]",
|
|
99
|
+
"[object Float32Array]",
|
|
100
|
+
"[object Float64Array]",
|
|
101
|
+
"[object BigInt64Array]",
|
|
102
|
+
"[object BigUint64Array]"
|
|
103
|
+
]);
|
|
104
|
+
const isTypedArray = (value) => {
|
|
105
|
+
return value != null && typeof value === "object" && typedArrayTags.has(Object.prototype.toString.call(value));
|
|
106
|
+
};
|
|
87
107
|
Object.defineProperty(exports, 'baseDeepEqual', {
|
|
88
108
|
enumerable: true,
|
|
89
109
|
get: function () {
|
|
@@ -102,10 +122,22 @@ Object.defineProperty(exports, 'isEqual', {
|
|
|
102
122
|
return isEqual;
|
|
103
123
|
}
|
|
104
124
|
});
|
|
125
|
+
Object.defineProperty(exports, 'isNonEmptyValue', {
|
|
126
|
+
enumerable: true,
|
|
127
|
+
get: function () {
|
|
128
|
+
return isNonEmptyValue;
|
|
129
|
+
}
|
|
130
|
+
});
|
|
105
131
|
Object.defineProperty(exports, 'isRegExp', {
|
|
106
132
|
enumerable: true,
|
|
107
133
|
get: function () {
|
|
108
134
|
return isRegExp;
|
|
109
135
|
}
|
|
110
136
|
});
|
|
111
|
-
|
|
137
|
+
Object.defineProperty(exports, 'isTypedArray', {
|
|
138
|
+
enumerable: true,
|
|
139
|
+
get: function () {
|
|
140
|
+
return isTypedArray;
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
//# sourceMappingURL=isTypedArray-DjADSu8q.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isTypedArray-DjADSu8q.cjs","names":["isObjectOrArray","isUndefined","isDate","isError","isMap","isSet","isArray","isEmptyValue"],"sources":["../src/predicates/is/isRegExp.ts","../src/predicates/is/isArrayBuffer.ts","../src/predicates/is/_private/baseDeepEqual.ts","../src/predicates/is/isEqual.ts","../src/predicates/is/isNonEmptyValue.ts","../src/predicates/is/isTypedArray.ts"],"sourcesContent":["/** ----------------------------------------------------------\n * * ***Type guard: `isRegExp`.***\n * -----------------------------------------------------------\n * **Checks if a value is a [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp) instance.**\n *\n * ---\n * @param {*} value - The value to check.\n *\n * ---\n * @returns {boolean} Return `true` if value is an instance of **`RegExp`**.\n *\n * ---\n * @example\n * isRegExp(/abc/);\n * // ➔ true\n * isRegExp(new RegExp(\"abc\"));\n * // ➔ true\n * isRegExp(\"abc\");\n * // ➔ false\n */\nexport const isRegExp = (value: unknown): value is RegExp => {\n return value instanceof RegExp;\n};\n","/** ----------------------------------------------------\n * * ***Type guard: `isArrayBuffer`.***\n * -----------------------------------------------------\n * **Checks if `value` is classified as an `ArrayBuffer` object.**\n *\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is instance of ***[`ArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer)***, else `false`.\n *\n * @example\n * isArrayBuffer(new ArrayBuffer(2));\n * // ➔ true\n * isArrayBuffer(new Array(2));\n * // ➔ false\n */\nexport const isArrayBuffer = (value: unknown): value is ArrayBuffer => {\n return value instanceof ArrayBuffer;\n};\n","import type { CustomizerIsEqualWith } from \"./types.isEqualWith\";\n\nimport { isMap } from \"../isMap\";\nimport { isSet } from \"../isSet\";\nimport { isDate } from \"../isDate\";\nimport { isArray } from \"../isArray\";\nimport { isError } from \"../isError\";\nimport { isRegExp } from \"../isRegExp\";\nimport { isUndefined } from \"../isUndefined\";\nimport { isArrayBuffer } from \"../isArrayBuffer\";\nimport { isObjectOrArray } from \"../isObjectOrArray\";\n\n/** -------------------------------------------------------------------\n * * ***Base function (**Internal**) for deep equality comparison with optional customizer.***\n * --------------------------------------------------------------------\n * **Recursively checks whether `value` and `other` are deeply equal. Supports custom comparison\n * via `customizer`, and handles arrays, objects, maps, sets, dates, errors, regexps, typed arrays,\n * and nested structures.**\n *\n * ---\n * @param value\n * - The value to compare.\n * @param other\n * - The other value to compare against.\n * @param customizer\n * - Optional function to customize the comparison for each property/value.\n * @param seen\n * - WeakMap used internally to track circular references and prevent infinite recursion.\n *\n * ---\n * @returns\n * - `true` ➔ `value` and `other` are deeply equal.\n * - `false` ➔ `value` and `other` are not deeply equal.\n *\n * ---\n * @example\n * ```ts\n * const obj1 = { name: \"Alice\", scores: [1, 2, 3] };\n * const obj2 = { name: \"alice\", scores: [1, 2, 3] };\n * const customizer: CustomizerIsEqualWith = (v, o) => {\n * if (typeof v === \"string\" && typeof o === \"string\") {\n * return v.toLowerCase() === o.toLowerCase();\n * }\n * };\n *\n * baseDeepEqual(obj1, obj2, customizer);\n * // ➔ true\n * ```\n */\nexport function baseDeepEqual(\n value: unknown,\n other: unknown,\n customizer?: CustomizerIsEqualWith,\n seen: WeakMap<object, object> = new WeakMap()\n): boolean {\n // ✅ Strict equality (+0 === -0)\n if (value === other) return true;\n\n // ✅ NaN === NaN\n if (value !== value && other !== other) return true;\n\n // ❌ Primitives mismatch\n if (!isObjectOrArray(value) || !isObjectOrArray(other)) {\n return false;\n }\n\n // ✅ Prevent circular recursion\n if (seen.get(value) === other) return true;\n seen.set(value, other);\n\n // ✅ Customizer support\n const callCustomizer = (\n v: unknown,\n o: unknown,\n key: PropertyKey,\n valObj: unknown,\n othObj: unknown\n ) => {\n if (customizer) {\n const result = customizer(v, o, key, valObj, othObj, seen);\n if (!isUndefined(result)) return result;\n }\n return baseDeepEqual(v, o, customizer, seen);\n };\n\n // ✅ Handle special instances\n if (isDate(value) && isDate(other))\n return value.getTime() === other.getTime();\n\n if (isRegExp(value) && isRegExp(other))\n return value.source === other.source && value.flags === other.flags;\n\n if (isError(value) && isError(other))\n return value.name === other.name && value.message === other.message;\n\n if (ArrayBuffer.isView(value) && ArrayBuffer.isView(other)) {\n const v = new Uint8Array(value.buffer, value.byteOffset, value.byteLength);\n const o = new Uint8Array(other.buffer, other.byteOffset, other.byteLength);\n if (v.length !== o.length) return false;\n for (let i = 0; i < v.length; i++) if (v[i] !== o[i]) return false;\n return true;\n }\n\n if (isArrayBuffer(value) && isArrayBuffer(other)) {\n if (value.byteLength !== other.byteLength) return false;\n const v = new Uint8Array(value),\n o = new Uint8Array(other);\n for (let i = 0; i < v.length; i++) if (v[i] !== o[i]) return false;\n return true;\n }\n\n if (isMap(value) && isMap(other)) {\n if (value.size !== other.size) return false;\n for (const [k, v] of value) {\n if (!other.has(k)) return false;\n if (!baseDeepEqual(v, other.get(k), customizer, seen)) return false;\n }\n return true;\n }\n\n if (isSet(value) && isSet(other)) {\n if (value.size !== other.size) return false;\n for (const v of value) {\n let matched = false;\n for (const o of other) {\n if (baseDeepEqual(v, o, customizer, seen)) {\n matched = true;\n break;\n }\n }\n if (!matched) return false;\n }\n return true;\n }\n\n if (isArray(value) && isArray(other)) {\n if (value.length !== other.length) return false;\n for (let i = 0; i < value.length; i++) {\n if (!callCustomizer(value[i], other[i], i, value, other)) return false;\n }\n return true;\n }\n\n if (Object.getPrototypeOf(value) !== Object.getPrototypeOf(other)) {\n return false;\n }\n\n const vKeys = Reflect.ownKeys(value);\n const oKeys = Reflect.ownKeys(other);\n if (vKeys.length !== oKeys.length) return false;\n\n for (const key of vKeys) {\n const vVal = value[key];\n const oVal = other[key];\n if (!callCustomizer(vVal, oVal, key, value, other)) return false;\n }\n\n return true;\n}\n","import { baseDeepEqual } from \"@/predicates/is/_private/baseDeepEqual\";\n\n/** ---------------------------------------------------------\n * * ***Predicate: `isEqual`.***\n * ----------------------------------------------------------\n * **Performs a deep comparison between two values to determine if they are equivalent.**\n *\n * ---\n * @description\n * Checks whether two values are **deeply equal**, not just reference-equal (`===`).\n *\n * ---\n * - #### *Behavior:*\n * - **This method compares:**\n * - Arrays and TypedArrays.\n * - ArrayBuffers.\n * - Plain objects (`Object`) ➔ own enumerable properties only.\n * - Booleans, Numbers, Strings, Symbols.\n * - Dates.\n * - Errors.\n * - Maps.\n * - Sets.\n * - Regular expressions.\n * - `Functions` and `DOM nodes` are ***not supported***.\n *\n * ---\n * @param {*} value The value to compare.\n * @param {*} other The other value to compare.\n *\n * ---\n * @returns {boolean} Returns `true` if the values are equivalent, else `false`.\n *\n * ---\n * @example\n * const obj1 = { user: \"fred\" };\n * const obj2 = { user: \"fred\" };\n *\n * isEqual(obj1, obj2);\n * // ➔ true\n * obj1 === obj2;\n * // ➔ false (different references)\n * isEqual([1, 2, 3], [1, 2, 3]);\n * // ➔ true\n * isEqual(new Date(\"2020-01-01\"), new Date(\"2020-01-01\"));\n * // ➔ true\n * isEqual(new Set([1, 2]), new Set([2, 1]));\n * // ➔ true\n * isEqual(/abc/i, new RegExp(\"abc\", \"i\"));\n * // ➔ true\n * isEqual({ a: 1 }, { a: 1, b: undefined });\n * // ➔ false\n */\nexport const isEqual = (value: unknown, other: unknown): boolean => {\n return baseDeepEqual(value, other, undefined, new WeakMap());\n};\n","import { isEmptyValue } from \"./isEmptyValue\";\n\ntype IsNonEmptyValueOptions = {\n /** ----------------------------------------------------------\n * * ***Whether to check symbol properties when checking empty objects, default: `false`.***\n * -----------------------------------------------------------\n *\n * @default false\n */\n checkSymbols?: boolean;\n};\n\n/** ----------------------------------------------------------\n * * ***Predicated: `isNonEmptyValue`.***\n * -----------------------------------------------------------\n * **Determines if a value is a **non-empty** object (`{}` with props), **non-empty** array (`[]` with items) or generally truthy.**\n *\n * ---\n * - #### *Behavior:*\n * - #### Returns `true` for:\n * - Objects **with properties**.\n * - Arrays **with items**.\n * - Non-empty, non-whitespace strings.\n * - Numbers (except `NaN`, includes `0`).\n * - Functions.\n * - `true`.\n * ---\n * - #### Returns `false` for:\n * - Empty objects (`{}`).\n * - Empty arrays (`[]`).\n * - `null` or `undefined`.\n * - Empty strings (`\"\"`) or whitespace-only strings (`\" \"`).\n * - `false`.\n * - `NaN`.\n * - #### Safely handles `null`, `undefined`, and non-object types without throwing.\n *\n * ---\n * @param {*} value - The value to evaluate.\n * @param {IsNonEmptyValueOptions} [options] - Optional settings.\n *\n * ---\n * @returns {boolean} Return `true` if the value is considered non-empty/truthy, otherwise `false`.\n *\n * ---\n * @example\n * isNonEmptyValue({});\n * // ➔ false\n * isNonEmptyValue([]);\n * // ➔ false\n * isNonEmptyValue({ key: \"value\" });\n * // ➔ true\n * isNonEmptyValue({ [Symbol(\"foo\")]: 123 });\n * // ➔ false (default `checkSymbols` is `false`)\n * isNonEmptyValue({ [Symbol(\"foo\")]: 123 }, { checkSymbols: true });\n * // ➔ true\n * isNonEmptyValue([1, 2, 3]);\n * // ➔ true\n * isNonEmptyValue(NaN);\n * // ➔ false\n * isNonEmptyValue(true);\n * // ➔ true\n * isNonEmptyValue(false);\n * // ➔ false\n * isNonEmptyValue(null);\n * // ➔ false\n * isNonEmptyValue(undefined);\n * // ➔ false\n * isNonEmptyValue(\"\");\n * // ➔ false\n * isNonEmptyValue(\" \");\n * // ➔ false\n * isNonEmptyValue(0);\n * // ➔ true\n * isNonEmptyValue(-1);\n * // ➔ true\n * isNonEmptyValue(2);\n * // ➔ true\n * isNonEmptyValue(() => {});\n * // ➔ true\n */\nexport const isNonEmptyValue = (\n value: unknown,\n options: IsNonEmptyValueOptions = {}\n): boolean => {\n return !isEmptyValue(value, options);\n};\n","import type { TypedArray } from \"@rzl-zone/ts-types-plus\";\n\nconst typedArrayTags = new Set([\n \"[object Int8Array]\",\n \"[object Uint8Array]\",\n \"[object Uint8ClampedArray]\",\n \"[object Int16Array]\",\n \"[object Uint16Array]\",\n \"[object Int32Array]\",\n \"[object Uint32Array]\",\n \"[object Float32Array]\",\n \"[object Float64Array]\",\n \"[object BigInt64Array]\",\n \"[object BigUint64Array]\"\n]);\n\n/** ---------------------------------------------------------\n * * ***Type guard: `isTypedArray`.***\n * ----------------------------------------------------------\n * **Checks if `value` is classified as a\n * **[`TypedArray`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray)**.**\n *\n * ---\n * - **Behavior:**\n * - Validates that `value` is a non-null object.\n * - Uses `Object.prototype.toString` tag matching against known typed array tags.\n * - Narrows type to **{@link TypedArray | `TypedArray`}** when true.\n *\n * ---\n * @param {*} value - The value to check.\n *\n * ---\n * @returns {boolean} Returns `true` if the value is a typed array, otherwise `false`.\n *\n * ---\n * @example\n * isTypedArray(new Uint8Array);\n * // ➔ true\n * isTypedArray(new Uint8Array());\n * // ➔ true\n * isTypedArray(new Float32Array());\n * // ➔ true\n * isTypedArray(new Uint8ClampedArray());\n * // ➔ true\n * isTypedArray([]);\n * // ➔ false\n * isTypedArray(Buffer.from(\"hi\"));\n * // ➔ false\n */\nexport const isTypedArray = (value: unknown): value is TypedArray => {\n return (\n value != null &&\n typeof value === \"object\" &&\n typedArrayTags.has(Object.prototype.toString.call(value))\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoBA,MAAa,YAAY,UAAoC;CAC3D,OAAO,iBAAiB;AAC1B;;;;;;;;;;;;;;;;;;ACRA,MAAa,iBAAiB,UAAyC;CACrE,OAAO,iBAAiB;AAC1B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACiCA,SAAgB,cACd,OACA,OACA,YACA,uBAAgC,IAAI,QAAQ,GACnC;CAET,IAAI,UAAU,OAAO,OAAO;CAG5B,IAAI,UAAU,SAAS,UAAU,OAAO,OAAO;CAG/C,IAAI,CAACA,+BAAgB,KAAK,KAAK,CAACA,+BAAgB,KAAK,GACnD,OAAO;CAIT,IAAI,KAAK,IAAI,KAAK,MAAM,OAAO,OAAO;CACtC,KAAK,IAAI,OAAO,KAAK;CAGrB,MAAM,kBACJ,GACA,GACA,KACA,QACA,WACG;EACH,IAAI,YAAY;GACd,MAAM,SAAS,WAAW,GAAG,GAAG,KAAK,QAAQ,QAAQ,IAAI;GACzD,IAAI,CAACC,wCAAY,MAAM,GAAG,OAAO;EACnC;EACA,OAAO,cAAc,GAAG,GAAG,YAAY,IAAI;CAC7C;CAGA,IAAIC,mCAAO,KAAK,KAAKA,mCAAO,KAAK,GAC/B,OAAO,MAAM,QAAQ,MAAM,MAAM,QAAQ;CAE3C,IAAI,SAAS,KAAK,KAAK,SAAS,KAAK,GACnC,OAAO,MAAM,WAAW,MAAM,UAAU,MAAM,UAAU,MAAM;CAEhE,IAAIC,uBAAQ,KAAK,KAAKA,uBAAQ,KAAK,GACjC,OAAO,MAAM,SAAS,MAAM,QAAQ,MAAM,YAAY,MAAM;CAE9D,IAAI,YAAY,OAAO,KAAK,KAAK,YAAY,OAAO,KAAK,GAAG;EAC1D,MAAM,IAAI,IAAI,WAAW,MAAM,QAAQ,MAAM,YA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,IAAI,CAAC,eAAe,MAAM,IAAI,MAAM,IAAI,GAAG,OAAO,KAAK,GAAG,OAAO;EAEnE,OAAO;CACT;CAEA,IAAI,OAAO,eAAe,KAAK,MAAM,OAAO,eAAe,KAAK,GAC9D,OAAO;CAGT,MAAM,QAAQ,QAAQ,QAAQ,KAAK;CACnC,MAAM,QAAQ,QAAQ,QAAQ,KAAK;CACnC,IAAI,MAAM,WAAW,MAAM,QAAQ,OAAO;CAE1C,KAAK,MAAM,OAAO,OAAO;EACvB,MAAM,OAAO,MAAM;EACnB,MAAM,OAAO,MAAM;EACnB,IAAI,CAAC,eAAe,MAAM,MAAM,KAAK,OAAO,KAAK,GAAG,OAAO;CAC7D;CAEA,OAAO;AACT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AC1GA,MAAa,WAAW,OAAgB,UAA4B;CAClE,OAAO,cAAc,OAAO,OAAO,wBAAW,IAAI,QAAQ,CAAC;AAC7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AC0BA,MAAa,mBACX,OACA,UAAkC,CAAC,MACvB;CACZ,OAAO,CAACC,kCAAa,OAAO,OAAO;AACrC;;;;ACnFA,MAAM,iBAAiB,IAAI,IAAI;CAC7B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCD,MAAa,gBAAgB,UAAwC;CACnE,OACE,SAAS,QACT,OAAO,UAAU,YACjB,eAAe,IAAI,OAAO,UAAU,SAAS,KAAK,KAAK,CAAC;AAE5D"}
|
|
@@ -2,19 +2,20 @@
|
|
|
2
2
|
* ========================================================================
|
|
3
3
|
* @rzl-zone/utils-js
|
|
4
4
|
* ------------------------------------------------------------------------
|
|
5
|
-
* Version: `3.
|
|
5
|
+
* Version: `3.14.0-beta.0`
|
|
6
6
|
* Author: `Rizalvin Dwiky <rizalvindwiky@gmail.com>`
|
|
7
7
|
* Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/utils-js`
|
|
8
8
|
* ========================================================================
|
|
9
9
|
*/
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
10
|
+
import { O as isArray, b as isError, g as isObjectOrArray, p as isSet } from "./logger-CLWnKRKE.js";
|
|
11
|
+
import { t as isEmptyValue } from "./isEmptyValue-kCjnLjbN.js";
|
|
12
|
+
import { a as isMap, i as isDate, r as isUndefined } from "./safeStableStringify-DfwxmiWn.js";
|
|
12
13
|
const isRegExp = (value) => {
|
|
13
14
|
return value instanceof RegExp;
|
|
14
15
|
};
|
|
15
|
-
|
|
16
|
+
const isArrayBuffer = (value) => {
|
|
16
17
|
return value instanceof ArrayBuffer;
|
|
17
|
-
}
|
|
18
|
+
};
|
|
18
19
|
function baseDeepEqual(value, other, customizer, seen = /* @__PURE__ */ new WeakMap()) {
|
|
19
20
|
if (value === other) return true;
|
|
20
21
|
if (value !== value && other !== other) return true;
|
|
@@ -80,8 +81,27 @@ function baseDeepEqual(value, other, customizer, seen = /* @__PURE__ */ new Weak
|
|
|
80
81
|
}
|
|
81
82
|
return true;
|
|
82
83
|
}
|
|
83
|
-
|
|
84
|
+
const isEqual = (value, other) => {
|
|
84
85
|
return baseDeepEqual(value, other, void 0, /* @__PURE__ */ new WeakMap());
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
|
|
86
|
+
};
|
|
87
|
+
const isNonEmptyValue = (value, options = {}) => {
|
|
88
|
+
return !isEmptyValue(value, options);
|
|
89
|
+
};
|
|
90
|
+
const typedArrayTags = new Set([
|
|
91
|
+
"[object Int8Array]",
|
|
92
|
+
"[object Uint8Array]",
|
|
93
|
+
"[object Uint8ClampedArray]",
|
|
94
|
+
"[object Int16Array]",
|
|
95
|
+
"[object Uint16Array]",
|
|
96
|
+
"[object Int32Array]",
|
|
97
|
+
"[object Uint32Array]",
|
|
98
|
+
"[object Float32Array]",
|
|
99
|
+
"[object Float64Array]",
|
|
100
|
+
"[object BigInt64Array]",
|
|
101
|
+
"[object BigUint64Array]"
|
|
102
|
+
]);
|
|
103
|
+
const isTypedArray = (value) => {
|
|
104
|
+
return value != null && typeof value === "object" && typedArrayTags.has(Object.prototype.toString.call(value));
|
|
105
|
+
};
|
|
106
|
+
export { isArrayBuffer as a, baseDeepEqual as i, isNonEmptyValue as n, isRegExp as o, isEqual as r, isTypedArray as t };
|
|
107
|
+
//# sourceMappingURL=isTypedArray-DxsPKrLh.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isTypedArray-DxsPKrLh.js","names":[],"sources":["../src/predicates/is/isRegExp.ts","../src/predicates/is/isArrayBuffer.ts","../src/predicates/is/_private/baseDeepEqual.ts","../src/predicates/is/isEqual.ts","../src/predicates/is/isNonEmptyValue.ts","../src/predicates/is/isTypedArray.ts"],"sourcesContent":["/** ----------------------------------------------------------\n * * ***Type guard: `isRegExp`.***\n * -----------------------------------------------------------\n * **Checks if a value is a [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp) instance.**\n *\n * ---\n * @param {*} value - The value to check.\n *\n * ---\n * @returns {boolean} Return `true` if value is an instance of **`RegExp`**.\n *\n * ---\n * @example\n * isRegExp(/abc/);\n * // ➔ true\n * isRegExp(new RegExp(\"abc\"));\n * // ➔ true\n * isRegExp(\"abc\");\n * // ➔ false\n */\nexport const isRegExp = (value: unknown): value is RegExp => {\n return value instanceof RegExp;\n};\n","/** ----------------------------------------------------\n * * ***Type guard: `isArrayBuffer`.***\n * -----------------------------------------------------\n * **Checks if `value` is classified as an `ArrayBuffer` object.**\n *\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is instance of ***[`ArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer)***, else `false`.\n *\n * @example\n * isArrayBuffer(new ArrayBuffer(2));\n * // ➔ true\n * isArrayBuffer(new Array(2));\n * // ➔ false\n */\nexport const isArrayBuffer = (value: unknown): value is ArrayBuffer => {\n return value instanceof ArrayBuffer;\n};\n","import type { CustomizerIsEqualWith } from \"./types.isEqualWith\";\n\nimport { isMap } from \"../isMap\";\nimport { isSet } from \"../isSet\";\nimport { isDate } from \"../isDate\";\nimport { isArray } from \"../isArray\";\nimport { isError } from \"../isError\";\nimport { isRegExp } from \"../isRegExp\";\nimport { isUndefined } from \"../isUndefined\";\nimport { isArrayBuffer } from \"../isArrayBuffer\";\nimport { isObjectOrArray } from \"../isObjectOrArray\";\n\n/** -------------------------------------------------------------------\n * * ***Base function (**Internal**) for deep equality comparison with optional customizer.***\n * --------------------------------------------------------------------\n * **Recursively checks whether `value` and `other` are deeply equal. Supports custom comparison\n * via `customizer`, and handles arrays, objects, maps, sets, dates, errors, regexps, typed arrays,\n * and nested structures.**\n *\n * ---\n * @param value\n * - The value to compare.\n * @param other\n * - The other value to compare against.\n * @param customizer\n * - Optional function to customize the comparison for each property/value.\n * @param seen\n * - WeakMap used internally to track circular references and prevent infinite recursion.\n *\n * ---\n * @returns\n * - `true` ➔ `value` and `other` are deeply equal.\n * - `false` ➔ `value` and `other` are not deeply equal.\n *\n * ---\n * @example\n * ```ts\n * const obj1 = { name: \"Alice\", scores: [1, 2, 3] };\n * const obj2 = { name: \"alice\", scores: [1, 2, 3] };\n * const customizer: CustomizerIsEqualWith = (v, o) => {\n * if (typeof v === \"string\" && typeof o === \"string\") {\n * return v.toLowerCase() === o.toLowerCase();\n * }\n * };\n *\n * baseDeepEqual(obj1, obj2, customizer);\n * // ➔ true\n * ```\n */\nexport function baseDeepEqual(\n value: unknown,\n other: unknown,\n customizer?: CustomizerIsEqualWith,\n seen: WeakMap<object, object> = new WeakMap()\n): boolean {\n // ✅ Strict equality (+0 === -0)\n if (value === other) return true;\n\n // ✅ NaN === NaN\n if (value !== value && other !== other) return true;\n\n // ❌ Primitives mismatch\n if (!isObjectOrArray(value) || !isObjectOrArray(other)) {\n return false;\n }\n\n // ✅ Prevent circular recursion\n if (seen.get(value) === other) return true;\n seen.set(value, other);\n\n // ✅ Customizer support\n const callCustomizer = (\n v: unknown,\n o: unknown,\n key: PropertyKey,\n valObj: unknown,\n othObj: unknown\n ) => {\n if (customizer) {\n const result = customizer(v, o, key, valObj, othObj, seen);\n if (!isUndefined(result)) return result;\n }\n return baseDeepEqual(v, o, customizer, seen);\n };\n\n // ✅ Handle special instances\n if (isDate(value) && isDate(other))\n return value.getTime() === other.getTime();\n\n if (isRegExp(value) && isRegExp(other))\n return value.source === other.source && value.flags === other.flags;\n\n if (isError(value) && isError(other))\n return value.name === other.name && value.message === other.message;\n\n if (ArrayBuffer.isView(value) && ArrayBuffer.isView(other)) {\n const v = new Uint8Array(value.buffer, value.byteOffset, value.byteLength);\n const o = new Uint8Array(other.buffer, other.byteOffset, other.byteLength);\n if (v.length !== o.length) return false;\n for (let i = 0; i < v.length; i++) if (v[i] !== o[i]) return false;\n return true;\n }\n\n if (isArrayBuffer(value) && isArrayBuffer(other)) {\n if (value.byteLength !== other.byteLength) return false;\n const v = new Uint8Array(value),\n o = new Uint8Array(other);\n for (let i = 0; i < v.length; i++) if (v[i] !== o[i]) return false;\n return true;\n }\n\n if (isMap(value) && isMap(other)) {\n if (value.size !== other.size) return false;\n for (const [k, v] of value) {\n if (!other.has(k)) return false;\n if (!baseDeepEqual(v, other.get(k), customizer, seen)) return false;\n }\n return true;\n }\n\n if (isSet(value) && isSet(other)) {\n if (value.size !== other.size) return false;\n for (const v of value) {\n let matched = false;\n for (const o of other) {\n if (baseDeepEqual(v, o, customizer, seen)) {\n matched = true;\n break;\n }\n }\n if (!matched) return false;\n }\n return true;\n }\n\n if (isArray(value) && isArray(other)) {\n if (value.length !== other.length) return false;\n for (let i = 0; i < value.length; i++) {\n if (!callCustomizer(value[i], other[i], i, value, other)) return false;\n }\n return true;\n }\n\n if (Object.getPrototypeOf(value) !== Object.getPrototypeOf(other)) {\n return false;\n }\n\n const vKeys = Reflect.ownKeys(value);\n const oKeys = Reflect.ownKeys(other);\n if (vKeys.length !== oKeys.length) return false;\n\n for (const key of vKeys) {\n const vVal = value[key];\n const oVal = other[key];\n if (!callCustomizer(vVal, oVal, key, value, other)) return false;\n }\n\n return true;\n}\n","import { baseDeepEqual } from \"@/predicates/is/_private/baseDeepEqual\";\n\n/** ---------------------------------------------------------\n * * ***Predicate: `isEqual`.***\n * ----------------------------------------------------------\n * **Performs a deep comparison between two values to determine if they are equivalent.**\n *\n * ---\n * @description\n * Checks whether two values are **deeply equal**, not just reference-equal (`===`).\n *\n * ---\n * - #### *Behavior:*\n * - **This method compares:**\n * - Arrays and TypedArrays.\n * - ArrayBuffers.\n * - Plain objects (`Object`) ➔ own enumerable properties only.\n * - Booleans, Numbers, Strings, Symbols.\n * - Dates.\n * - Errors.\n * - Maps.\n * - Sets.\n * - Regular expressions.\n * - `Functions` and `DOM nodes` are ***not supported***.\n *\n * ---\n * @param {*} value The value to compare.\n * @param {*} other The other value to compare.\n *\n * ---\n * @returns {boolean} Returns `true` if the values are equivalent, else `false`.\n *\n * ---\n * @example\n * const obj1 = { user: \"fred\" };\n * const obj2 = { user: \"fred\" };\n *\n * isEqual(obj1, obj2);\n * // ➔ true\n * obj1 === obj2;\n * // ➔ false (different references)\n * isEqual([1, 2, 3], [1, 2, 3]);\n * // ➔ true\n * isEqual(new Date(\"2020-01-01\"), new Date(\"2020-01-01\"));\n * // ➔ true\n * isEqual(new Set([1, 2]), new Set([2, 1]));\n * // ➔ true\n * isEqual(/abc/i, new RegExp(\"abc\", \"i\"));\n * // ➔ true\n * isEqual({ a: 1 }, { a: 1, b: undefined });\n * // ➔ false\n */\nexport const isEqual = (value: unknown, other: unknown): boolean => {\n return baseDeepEqual(value, other, undefined, new WeakMap());\n};\n","import { isEmptyValue } from \"./isEmptyValue\";\n\ntype IsNonEmptyValueOptions = {\n /** ----------------------------------------------------------\n * * ***Whether to check symbol properties when checking empty objects, default: `false`.***\n * -----------------------------------------------------------\n *\n * @default false\n */\n checkSymbols?: boolean;\n};\n\n/** ----------------------------------------------------------\n * * ***Predicated: `isNonEmptyValue`.***\n * -----------------------------------------------------------\n * **Determines if a value is a **non-empty** object (`{}` with props), **non-empty** array (`[]` with items) or generally truthy.**\n *\n * ---\n * - #### *Behavior:*\n * - #### Returns `true` for:\n * - Objects **with properties**.\n * - Arrays **with items**.\n * - Non-empty, non-whitespace strings.\n * - Numbers (except `NaN`, includes `0`).\n * - Functions.\n * - `true`.\n * ---\n * - #### Returns `false` for:\n * - Empty objects (`{}`).\n * - Empty arrays (`[]`).\n * - `null` or `undefined`.\n * - Empty strings (`\"\"`) or whitespace-only strings (`\" \"`).\n * - `false`.\n * - `NaN`.\n * - #### Safely handles `null`, `undefined`, and non-object types without throwing.\n *\n * ---\n * @param {*} value - The value to evaluate.\n * @param {IsNonEmptyValueOptions} [options] - Optional settings.\n *\n * ---\n * @returns {boolean} Return `true` if the value is considered non-empty/truthy, otherwise `false`.\n *\n * ---\n * @example\n * isNonEmptyValue({});\n * // ➔ false\n * isNonEmptyValue([]);\n * // ➔ false\n * isNonEmptyValue({ key: \"value\" });\n * // ➔ true\n * isNonEmptyValue({ [Symbol(\"foo\")]: 123 });\n * // ➔ false (default `checkSymbols` is `false`)\n * isNonEmptyValue({ [Symbol(\"foo\")]: 123 }, { checkSymbols: true });\n * // ➔ true\n * isNonEmptyValue([1, 2, 3]);\n * // ➔ true\n * isNonEmptyValue(NaN);\n * // ➔ false\n * isNonEmptyValue(true);\n * // ➔ true\n * isNonEmptyValue(false);\n * // ➔ false\n * isNonEmptyValue(null);\n * // ➔ false\n * isNonEmptyValue(undefined);\n * // ➔ false\n * isNonEmptyValue(\"\");\n * // ➔ false\n * isNonEmptyValue(\" \");\n * // ➔ false\n * isNonEmptyValue(0);\n * // ➔ true\n * isNonEmptyValue(-1);\n * // ➔ true\n * isNonEmptyValue(2);\n * // ➔ true\n * isNonEmptyValue(() => {});\n * // ➔ true\n */\nexport const isNonEmptyValue = (\n value: unknown,\n options: IsNonEmptyValueOptions = {}\n): boolean => {\n return !isEmptyValue(value, options);\n};\n","import type { TypedArray } from \"@rzl-zone/ts-types-plus\";\n\nconst typedArrayTags = new Set([\n \"[object Int8Array]\",\n \"[object Uint8Array]\",\n \"[object Uint8ClampedArray]\",\n \"[object Int16Array]\",\n \"[object Uint16Array]\",\n \"[object Int32Array]\",\n \"[object Uint32Array]\",\n \"[object Float32Array]\",\n \"[object Float64Array]\",\n \"[object BigInt64Array]\",\n \"[object BigUint64Array]\"\n]);\n\n/** ---------------------------------------------------------\n * * ***Type guard: `isTypedArray`.***\n * ----------------------------------------------------------\n * **Checks if `value` is classified as a\n * **[`TypedArray`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray)**.**\n *\n * ---\n * - **Behavior:**\n * - Validates that `value` is a non-null object.\n * - Uses `Object.prototype.toString` tag matching against known typed array tags.\n * - Narrows type to **{@link TypedArray | `TypedArray`}** when true.\n *\n * ---\n * @param {*} value - The value to check.\n *\n * ---\n * @returns {boolean} Returns `true` if the value is a typed array, otherwise `false`.\n *\n * ---\n * @example\n * isTypedArray(new Uint8Array);\n * // ➔ true\n * isTypedArray(new Uint8Array());\n * // ➔ true\n * isTypedArray(new Float32Array());\n * // ➔ true\n * isTypedArray(new Uint8ClampedArray());\n * // ➔ true\n * isTypedArray([]);\n * // ➔ false\n * isTypedArray(Buffer.from(\"hi\"));\n * // ➔ false\n */\nexport const isTypedArray = (value: unknown): value is TypedArray => {\n return (\n value != null &&\n typeof value === \"object\" &&\n typedArrayTags.has(Object.prototype.toString.call(value))\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoBA,MAAa,YAAY,UAAoC;CAC3D,OAAO,iBAAiB;AAC1B;;;;;;;;;;;;;;;;;;ACRA,MAAa,iBAAiB,UAAyC;CACrE,OAAO,iBAAiB;AAC1B;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AO,MAAM;EACnB,MAAM,OAAO,MAAM;EACnB,IAAI,CAAC,eAAe,MAAM,MAAM,KAAK,OAAO,KAAK,GAAG,OAAO;CAC7D;CAEA,OAAO;AACT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AC1GA,MAAa,WAAW,OAAgB,UAA4B;CAClE,OAAO,cAAc,OAAO,OAAO,wBAAW,IAAI,QAAQ,CAAC;AAC7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AC0BA,MAAa,mBACX,OACA,UAAkC,CAAC,MACvB;CACZ,OAAO,CAAC,aAAa,OAAO,OAAO;AACrC;;;;ACnFA,MAAM,iBAAiB,IAAI,IAAI;CAC7B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCD,MAAa,gBAAgB,UAAwC;CACnE,OACE,SAAS,QACT,OAAO,UAAU,YACjB,eAAe,IAAI,OAAO,UAAU,SAAS,KAAK,KAAK,CAAC;AAE5D"}
|
|
@@ -2,61 +2,19 @@
|
|
|
2
2
|
* ========================================================================
|
|
3
3
|
* @rzl-zone/utils-js
|
|
4
4
|
* ------------------------------------------------------------------------
|
|
5
|
-
* Version: `3.
|
|
5
|
+
* Version: `3.14.0-beta.0`
|
|
6
6
|
* Author: `Rizalvin Dwiky <rizalvindwiky@gmail.com>`
|
|
7
7
|
* Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/utils-js`
|
|
8
8
|
* ========================================================================
|
|
9
9
|
*/
|
|
10
|
-
import {
|
|
11
|
-
import { t as
|
|
12
|
-
import { t as
|
|
10
|
+
import { T as isString, i as getPreciseType, j as isBoolean, t as createMessage } from "./logger-CLWnKRKE.js";
|
|
11
|
+
import { t as assertIsPlainObject } from "./assertIsPlainObject-j9bDqNLo.js";
|
|
12
|
+
import { t as safeStableStringify } from "./safeStableStringify-DfwxmiWn.js";
|
|
13
|
+
import { n as joinLines, t as EOL } from "./formatter-ekJQF_bA-xLD9mGk4.js";
|
|
14
|
+
import { t as punycodeUtilsJS } from "./punyCode-Deb1Mrkc.js";
|
|
13
15
|
const isURL = (value) => {
|
|
14
16
|
return value instanceof URL;
|
|
15
17
|
};
|
|
16
|
-
/*!
|
|
17
|
-
* ========================================================================
|
|
18
|
-
* @rzl-zone/build-tools
|
|
19
|
-
* ------------------------------------------------------------------------
|
|
20
|
-
* Version: `0.0.12`
|
|
21
|
-
* Author: `Rizalvin Dwiky <rizalvindwiky1998@gmail.com>`
|
|
22
|
-
* Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/build-tools`
|
|
23
|
-
* ========================================================================
|
|
24
|
-
*/
|
|
25
|
-
function isArray(value) {
|
|
26
|
-
return Array.isArray(value);
|
|
27
|
-
}
|
|
28
|
-
function isObject(value) {
|
|
29
|
-
return typeof value === "object" && !isNil(value) && !isArray(value);
|
|
30
|
-
}
|
|
31
|
-
const isNil = (value) => {
|
|
32
|
-
return value == null;
|
|
33
|
-
};
|
|
34
|
-
const isFunction = (value) => {
|
|
35
|
-
return typeof value === "function";
|
|
36
|
-
};
|
|
37
|
-
const hasGlobalRequire = (value) => isObject(value) && isFunction(value.require);
|
|
38
|
-
const getRuntimeRequire = () => {
|
|
39
|
-
if (!hasGlobalRequire(globalThis)) return void 0;
|
|
40
|
-
return globalThis.require;
|
|
41
|
-
};
|
|
42
|
-
const __runtimeRequire = ((x) => {
|
|
43
|
-
const r = getRuntimeRequire();
|
|
44
|
-
if (r) return r;
|
|
45
|
-
if (typeof Proxy !== "undefined") return new Proxy(x, { get(target, prop) {
|
|
46
|
-
const r2 = getRuntimeRequire();
|
|
47
|
-
return r2 ? r2[prop] : target[prop];
|
|
48
|
-
} });
|
|
49
|
-
return x;
|
|
50
|
-
})(function(id) {
|
|
51
|
-
const r = getRuntimeRequire();
|
|
52
|
-
if (r) return r.call(this, id);
|
|
53
|
-
throw new Error(`Calling \`require\` for "${id}" in an environment that doesn't expose the \`require\` function.`);
|
|
54
|
-
});
|
|
55
|
-
const NEWLINE = atob("Cg==");
|
|
56
|
-
const EOL = hasGlobalRequire(globalThis) ? __runtimeRequire("node:os").EOL : NEWLINE;
|
|
57
|
-
function joinLines(...text) {
|
|
58
|
-
return text.filter(Boolean).join(EOL);
|
|
59
|
-
}
|
|
60
18
|
var sldMap_default = {
|
|
61
19
|
"com.ac": true,
|
|
62
20
|
"net.ac": true,
|
|
@@ -1751,9 +1709,9 @@ var ccTldMap_default = {
|
|
|
1751
1709
|
zm: true,
|
|
1752
1710
|
zw: true
|
|
1753
1711
|
};
|
|
1754
|
-
|
|
1712
|
+
const isValidDomain = (value, options = {}) => {
|
|
1755
1713
|
if (!isString(value)) return false;
|
|
1756
|
-
assertIsPlainObject(options, { message: ({ currentType, validType }) => `Second parameter (\`options\`) must be of type \`${validType}\`, but received: \`${currentType}\`.` });
|
|
1714
|
+
assertIsPlainObject(options, { message: ({ currentType, validType }) => errorMsg(`Second parameter (\`options\`) must be of type \`${validType}\`, but received: \`${currentType}\`.`) });
|
|
1757
1715
|
const { subdomain = true, topLevel = false, wildcard = false, allowUnicode = false, allowPort = false, allowLocalhost = false, allowProtocol = false } = options;
|
|
1758
1716
|
const invalid = Object.entries({
|
|
1759
1717
|
subdomain,
|
|
@@ -1768,7 +1726,7 @@ function isValidDomain(value, options = {}) {
|
|
|
1768
1726
|
const msg = invalid.map(([key, value], i) => {
|
|
1769
1727
|
return joinLines(` ${i + 1}. option: "${key}"`, " expected: boolean", ` received: ${getPreciseType(value)} (${safeStableStringify(value, { keepUndefined: true })})`);
|
|
1770
1728
|
}).join(EOL);
|
|
1771
|
-
throw new TypeError(joinLines("", "> Invalid options detected in second parameter
|
|
1729
|
+
throw new TypeError(errorMsg(joinLines("", "> Invalid options detected in second parameter:", msg)));
|
|
1772
1730
|
}
|
|
1773
1731
|
let _value = value.toLowerCase();
|
|
1774
1732
|
if (allowProtocol) try {
|
|
@@ -1825,6 +1783,7 @@ function isValidDomain(value, options = {}) {
|
|
|
1825
1783
|
if (index === labels.length - 1 && doubleDashCount !== xnDashCount) return false;
|
|
1826
1784
|
return validLabelChars.test(label) && label.length < 64 && !label.startsWith("-") && !label.endsWith("-");
|
|
1827
1785
|
});
|
|
1828
|
-
}
|
|
1829
|
-
|
|
1830
|
-
|
|
1786
|
+
};
|
|
1787
|
+
const errorMsg = (msg) => createMessage("isValidDomain", msg);
|
|
1788
|
+
export { isURL as n, isValidDomain as t };
|
|
1789
|
+
//# sourceMappingURL=isValidDomain-CDtNOhMc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isValidDomain-CDtNOhMc.js","names":["ccTldMap","sldMap"],"sources":["../src/predicates/is/isURL.ts","../src/predicates/is/_private/data/domain/sldMap.json","../src/predicates/is/_private/data/domain/ccTldMap.json","../src/predicates/is/isValidDomain.ts"],"sourcesContent":["/** ---------------------------------------------------------\n * * ***Type guard: `isURL`.***\n * ----------------------------------------------------------\n * **Checks if a value is an instance of the\n * **[`URL`](https://developer.mozilla.org/docs/Web/API/URL)** class.**\n *\n * ---\n * - **Behavior:**\n * - Narrows type to `URL` when true.\n * - Excludes `strings`, `plain-objects`, and `other non-URL values`.\n *\n * ---\n * @param {*} value - The value to check.\n *\n * ---\n * @returns {boolean} Returns `true` if the value is an instance of `URL`, otherwise `false`.\n *\n * ---\n * @example\n * isURL(new URL(\"https://example.com\"));\n * // ➔ true\n * isURL(\"https://example.com\");\n * // ➔ false\n */\nexport const isURL = (value: unknown): value is URL => {\n return value instanceof URL;\n};\n","","","import { joinLines, EOL } from \"@rzl-zone/build-tools/utils\";\n\nimport { createMessage } from \"@/_private/logger\";\n\nimport { punycodeUtilsJS } from \"@/urls/utils/punyCode\";\nimport { assertIsPlainObject } from \"@/assertions/objects/assertIsPlainObject\";\nimport { safeStableStringify } from \"@/conversions/stringify/safeStableStringify\";\n\nimport sldMap from \"./_private/data/domain/sldMap.json\";\nimport ccTldMap from \"./_private/data/domain/ccTldMap.json\";\n\nimport { isString } from \"./isString\";\nimport { isBoolean } from \"./isBoolean\";\n\nimport { getPreciseType } from \"../type/getPreciseType\";\n\n/** ---------------------------------------------------------\n * * ***Options for `isValidDomain` predicate.***\n * ----------------------------------------------------------\n * **Customize the behavior of domain validation.**\n */\ntype IsValidDomainOptions = {\n /** ---------------------------------------------------------\n * * ***Enable conversion of Unicode domains (IDN) to ASCII (punycode).***\n * ----------------------------------------------------------\n *\n * - Example:\n * - `\"пример.рф\"` ➔ `\"xn--e1afmkfd.xn--p1ai\"`.\n * - Allows validating Unicode domains correctly.\n * - Default: `false`.\n *\n * ---\n * @default\n * ```ts\n * false\n * ```\n */\n allowUnicode?: boolean;\n\n /** ---------------------------------------------------------\n * * ***If `true`, validates **only top-level domains (TLDs)** that are not part of any SLD/second-level domain.***\n * ----------------------------------------------------------\n *\n * - Behavior:\n * - Accepts country-code TLDs like `\"ai\"` or `\"ai.\"` ✅.\n * - Rejects common TLDs that are part of SLDs like `\"com\"` ❌.\n * - Only the final label is checked; subdomains are ignored.\n * - Default: `false`.\n *\n * ---\n * @default\n * ```ts\n * false\n * ```\n */\n topLevel?: boolean;\n\n /** ---------------------------------------------------------\n * * ***Allow or disallow subdomains.***\n * ----------------------------------------------------------\n *\n * - Example:\n * - `\"sub.example.com\"` ✅ if `subdomain` is `true`, ❌ if `false`.\n * - Wildcards and SLDs are considered when evaluating subdomains.\n * - Default: `true`.\n *\n * ---\n * @default\n * ```ts\n * true\n * ```\n */\n subdomain?: boolean;\n\n /** ---------------------------------------------------------\n * * ***Allow a wildcard `*` in the left-most label.***\n * ----------------------------------------------------------\n *\n * - Example:\n * - `\"*.example.com\"` ✅ if `wildcard` is `true`, ❌ if `false`.\n * - Wildcards are only valid in the first label and require at least one additional label.\n * - Default: `false`.\n *\n * ---\n * @default\n * ```ts\n * false\n * ```\n */\n wildcard?: boolean;\n\n /** ---------------------------------------------------------\n * * ***Allow a port after the domain.***\n * ----------------------------------------------------------\n *\n * - Example:\n * - `\"localhost:3000\"` or `\"example.com:8080\"` ✅ if `allowPort` is `true`.\n * - Validates that the port is a number between `1` and `65535`.\n * - Does not affect domain validation rules otherwise.\n * - Default: `false`.\n *\n * ---\n * @default\n * ```ts\n * false\n * ```\n */\n allowPort?: boolean;\n\n /** ---------------------------------------------------------\n * * ***Allow special domains like `localhost`.***\n * ----------------------------------------------------------\n *\n * - Example:\n * - `\"localhost\"` ✅ if `allowLocalhost` is `true`.\n * - Works with or without a port if `allowPort` is enabled.\n * - Default: `false`.\n *\n * ---\n * @default\n * ```ts\n * false\n * ```\n */\n allowLocalhost?: boolean;\n\n /** ---------------------------------------------------------\n * * ***Allow URLs with protocol (`http`/`https`) and automatically extract the hostname.***\n * ----------------------------------------------------------\n *\n * - Example:\n * - `\"https://example.com/foo/bar\"` ➔ `\"example.com\"`.\n * - The function will validate only the hostname part and ***ignore*** the `path`, `query`, and `fragment`.\n * - Default: `false`.\n *\n * ---\n * @default\n * ```ts\n * false\n * ```\n */\n allowProtocol?: boolean;\n};\n\n/** ---------------------------------------------------------\n * * ***Predicate: `isValidDomain`.***\n * ----------------------------------------------------------\n * **Validates whether a given string is a properly formatted domain name.**\n *\n * ---\n * - #### *Behavior:*\n * - Supports options for:\n * - `allowUnicode` ➔ allows internationalized domain names (IDN) with Unicode characters.\n * - `topLevel` ➔ validates **only top-level domains (TLDs)**; ignores subdomains and SLDs.\n * - `subdomain` ➔ allows or disallows subdomains.\n * - `wildcard` ➔ allows wildcard (`*`) in the left-most label.\n * - `allowPort` ➔ allows a port number after the domain (e.g., `example.com:8080`).\n * - `allowLocalhost` ➔ allows the special domain `\"localhost\"`.\n * - `allowProtocol` ➔ allows a URL with protocol (`http`/`https`) and extracts the hostname.\n * - Converts Unicode to ASCII (punycode) if `allowUnicode` is `true`.\n * - Checks label lengths (`≤63` chars), valid characters, and punycode consistency.\n * - Validates port if `allowPort` is `true` (must be 1–65535).\n * - Accepts `\"localhost\"` if `allowLocalhost` is `true`.\n * - Extracts hostname from URLs if `allowProtocol` is `true`.\n * - Rejects invalid domains, labels starting/ending with `-`, double dots, malformed TLDs, or invalid port numbers.\n * - Handles both standard domains (`example.com`), URLs with protocols (`https://example.com/foo`), and IDNs (`пример.рф`).\n *\n * ---\n * @param {*} value - The value to validate; only strings are valid domains.\n * @param {IsValidDomainOptions} [options] - Optional configuration for domain validation.\n * @param {boolean} [options.allowUnicode=false] - Enable punycode conversion for Unicode domains.\n * @param {boolean} [options.topLevel=false] - Validate only TLDs (e.g., `ai`, `uk.`); ignores SLDs like `com`.\n * @param {boolean} [options.subdomain=true] - Allow subdomains; set `false` to reject any subdomain.\n * @param {boolean} [options.wildcard=false] - Allow wildcard `*` in the left-most label (e.g., `*.example.com`).\n * @param {boolean} [options.allowPort=false] - Allow port number after domain (e.g., `:3000`); must be 1–65535.\n * @param {boolean} [options.allowLocalhost=false] - Allow special domain `\"localhost\"`.\n * @param {boolean} [options.allowProtocol=false] - Allow URLs with protocol (`http`/`https`) and extract hostname only.\n *\n * ---\n * @returns {boolean} Returns `true` if the value is a valid domain according to the rules and options; otherwise `false`.\n *\n * ---\n * @example\n * isValidDomain(\"google.com\");\n * // ➔ true\n * isValidDomain(\"пример.рф\", { allowUnicode: true });\n * // ➔ true\n * isValidDomain(\"sub.example.com\", { subdomain: false });\n * // ➔ false\n * isValidDomain(\"*.example.com\", { wildcard: true });\n * // ➔ true\n * isValidDomain(\"com\", { topLevel: true });\n * // ➔ false (common TLD rejected because it's part of SLD)\n * isValidDomain(\"ai.\", { topLevel: true });\n * // ➔ true (country-code TLD accepted)\n * isValidDomain(\"localhost\", { allowLocalhost: true });\n * // ➔ true\n * isValidDomain(\"localhost:3000\", { allowLocalhost: true, allowPort: true });\n * // ➔ true\n * isValidDomain(\"example.com:8080\", { allowPort: true });\n * // ➔ true\n * isValidDomain(\"https://example.com/foo/bar\", { allowProtocol: true });\n * // ➔ true (protocol stripped and hostname validated)\n * isValidDomain(\"invalid_domain.com\");\n * // ➔ false\n */\nexport const isValidDomain = (\n value: unknown,\n options: IsValidDomainOptions = {}\n): boolean => {\n if (!isString(value)) return false;\n\n assertIsPlainObject(options, {\n message: ({ currentType, validType }) =>\n errorMsg(\n `Second parameter (\\`options\\`) must be of type \\`${validType}\\`, but received: \\`${currentType}\\`.`\n )\n });\n\n const {\n subdomain = true,\n topLevel = false,\n wildcard = false,\n allowUnicode = false,\n allowPort = false,\n allowLocalhost = false,\n allowProtocol = false\n } = options;\n\n // Validate Options:\n const invalid = Object.entries({\n subdomain,\n topLevel,\n wildcard,\n allowUnicode,\n allowProtocol,\n allowPort,\n allowLocalhost\n }).filter(([, value]) => !isBoolean(value));\n\n if (invalid.length) {\n const msg = invalid\n .map(([key, value], i) => {\n return joinLines(\n ` ${i + 1}. option: \"${key}\"`,\n \" expected: boolean\",\n ` received: ${getPreciseType(value)} (${safeStableStringify(\n value,\n {\n keepUndefined: true\n }\n )})`\n );\n })\n .join(EOL);\n\n throw new TypeError(\n errorMsg(\n joinLines(\"\", \"> Invalid options detected in second parameter:\", msg)\n )\n );\n }\n\n // -----------------\n\n let _value = value.toLowerCase();\n\n if (allowProtocol) {\n try {\n const url = new URL(value); // use original input\n if (url.protocol !== \"http:\" && url.protocol !== \"https:\") return false; // reject non-http(s)\n if (!allowPort && url.port) return false; // reject port if allowPort=false\n _value = url.hostname.toLowerCase(); // extract only hostname\n\n // wildcard check\n const labels = _value.split(\".\");\n if (labels[0] === \"*\" && !wildcard) return false;\n } catch {\n // if parsing fails, leave _value unchanged\n }\n }\n\n if (value.endsWith(\".\")) {\n _value = _value.slice(0, _value.length - 1);\n }\n\n // Handle port\n let port: string;\n if (allowPort) {\n const portMatch = _value.match(/:(\\d{1,5})$/);\n if (portMatch) {\n port = portMatch[0];\n _value = _value.slice(0, -port.length);\n const portNum = Number(portMatch[1]);\n if (portNum < 1 || portNum > 65535) return false;\n }\n }\n\n // Allow localhost\n if (allowLocalhost && _value === \"localhost\") return true;\n\n if (allowUnicode) {\n try {\n _value = punycodeUtilsJS.toASCII(_value);\n } catch {\n return false;\n }\n }\n\n if (_value.length > 253) return false;\n\n const validChars = /^([\\u0E00-\\u0E7Fa-z0-9-._*]+)$/g;\n if (!validChars.test(_value)) return false;\n\n if (topLevel) {\n if (ccTldMap[_value.replace(/\\.$/, \"\") as keyof typeof ccTldMap]) {\n return true;\n }\n }\n\n const sldRegex = /(.*)\\.(([\\u0E00-\\u0E7Fa-z0-9]+)(\\.[a-z0-9]+))/;\n const matches = _value.match(sldRegex);\n // eslint-disable-next-line no-useless-assignment\n let tld: string | null = null;\n let labels: string[] | null = null;\n\n if (matches && matches.length > 2) {\n if (sldMap[matches[2] as keyof typeof sldMap]) {\n // eslint-disable-next-line no-useless-assignment\n tld = matches[2] || null;\n labels = matches[1]?.split(\".\") || null;\n }\n }\n\n if (!labels) {\n labels = _value.split(\".\");\n if (labels.length <= 1) return false;\n\n tld = labels.pop()!;\n const tldRegex = /^(?:xn--)?(?!^\\d+$)[\\u0E00-\\u0E7Fa-z0-9]+$/gi;\n if (!tldRegex.test(tld)) return false;\n }\n\n if (subdomain === false && labels.length > 1) return false;\n\n return labels.every((label, index) => {\n if (wildcard && index === 0 && label === \"*\" && labels.length > 1) {\n return true;\n }\n\n let validLabelChars = /^([\\u0E00-\\u0E7Fa-zA-Z0-9-_]+)$/g;\n if (index === labels.length - 1) {\n validLabelChars = /^([\\u0E00-\\u0E7Fa-zA-Z0-9-]+)$/g;\n }\n\n const doubleDashCount = (label.match(/--(--)?/g) || []).length;\n const xnDashCount = (label.match(/xn--/g) || []).length;\n if (index === labels.length - 1 && doubleDashCount !== xnDashCount) {\n return false;\n }\n\n return (\n validLabelChars.test(label) &&\n label.length < 64 &&\n !label.startsWith(\"-\") &&\n !label.endsWith(\"-\")\n );\n });\n};\n\n/**\n * @internal ***`Not part of the public API.`***\n */\nconst errorMsg = (msg: string) => createMessage(\"isValidDomain\", msg);\n"],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------------------------------------------------------------
|
|
5
|
-
* Version: `3.
|
|
5
|
+
* Version: `3.14.0-beta.0`
|
|
6
6
|
* Author: `Rizalvin Dwiky <rizalvindwiky@gmail.com>`
|
|
7
7
|
* Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/utils-js`
|
|
8
8
|
* ========================================================================
|
|
9
9
|
*/
|
|
10
10
|
"use strict";
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
11
|
+
const require_logger = require('./logger-CUacYy3D.cjs');
|
|
12
|
+
const require_assertIsPlainObject = require('./assertIsPlainObject-DPZLj-Ho.cjs');
|
|
13
|
+
const require_safeStableStringify = require('./safeStableStringify-C5HHKUdn.cjs');
|
|
14
|
+
const require_formatter_ekJQF_bA = require('./formatter-ekJQF_bA-BepnCBkQ.cjs');
|
|
15
|
+
const require_punyCode = require('./punyCode-DHTLhGdD.cjs');
|
|
14
16
|
const isURL = (value) => {
|
|
15
17
|
return value instanceof URL;
|
|
16
18
|
};
|
|
17
|
-
/*!
|
|
18
|
-
* ========================================================================
|
|
19
|
-
* @rzl-zone/build-tools
|
|
20
|
-
* ------------------------------------------------------------------------
|
|
21
|
-
* Version: `0.0.12`
|
|
22
|
-
* Author: `Rizalvin Dwiky <rizalvindwiky1998@gmail.com>`
|
|
23
|
-
* Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/build-tools`
|
|
24
|
-
* ========================================================================
|
|
25
|
-
*/
|
|
26
|
-
function isArray(value) {
|
|
27
|
-
return Array.isArray(value);
|
|
28
|
-
}
|
|
29
|
-
function isObject(value) {
|
|
30
|
-
return typeof value === "object" && !isNil(value) && !isArray(value);
|
|
31
|
-
}
|
|
32
|
-
const isNil = (value) => {
|
|
33
|
-
return value == null;
|
|
34
|
-
};
|
|
35
|
-
const isFunction = (value) => {
|
|
36
|
-
return typeof value === "function";
|
|
37
|
-
};
|
|
38
|
-
const hasGlobalRequire = (value) => isObject(value) && isFunction(value.require);
|
|
39
|
-
const getRuntimeRequire = () => {
|
|
40
|
-
if (!hasGlobalRequire(globalThis)) return void 0;
|
|
41
|
-
return globalThis.require;
|
|
42
|
-
};
|
|
43
|
-
const __runtimeRequire = ((x) => {
|
|
44
|
-
const r = getRuntimeRequire();
|
|
45
|
-
if (r) return r;
|
|
46
|
-
if (typeof Proxy !== "undefined") return new Proxy(x, { get(target, prop) {
|
|
47
|
-
const r2 = getRuntimeRequire();
|
|
48
|
-
return r2 ? r2[prop] : target[prop];
|
|
49
|
-
} });
|
|
50
|
-
return x;
|
|
51
|
-
})(function(id) {
|
|
52
|
-
const r = getRuntimeRequire();
|
|
53
|
-
if (r) return r.call(this, id);
|
|
54
|
-
throw new Error(`Calling \`require\` for "${id}" in an environment that doesn't expose the \`require\` function.`);
|
|
55
|
-
});
|
|
56
|
-
const NEWLINE = atob("Cg==");
|
|
57
|
-
const EOL = hasGlobalRequire(globalThis) ? __runtimeRequire("node:os").EOL : NEWLINE;
|
|
58
|
-
function joinLines(...text) {
|
|
59
|
-
return text.filter(Boolean).join(EOL);
|
|
60
|
-
}
|
|
61
19
|
var sldMap_default = {
|
|
62
20
|
"com.ac": true,
|
|
63
21
|
"net.ac": true,
|
|
@@ -1752,9 +1710,9 @@ var ccTldMap_default = {
|
|
|
1752
1710
|
zm: true,
|
|
1753
1711
|
zw: true
|
|
1754
1712
|
};
|
|
1755
|
-
|
|
1756
|
-
if (!
|
|
1757
|
-
|
|
1713
|
+
const isValidDomain = (value, options = {}) => {
|
|
1714
|
+
if (!require_logger.isString(value)) return false;
|
|
1715
|
+
require_assertIsPlainObject.assertIsPlainObject(options, { message: ({ currentType, validType }) => errorMsg(`Second parameter (\`options\`) must be of type \`${validType}\`, but received: \`${currentType}\`.`) });
|
|
1758
1716
|
const { subdomain = true, topLevel = false, wildcard = false, allowUnicode = false, allowPort = false, allowLocalhost = false, allowProtocol = false } = options;
|
|
1759
1717
|
const invalid = Object.entries({
|
|
1760
1718
|
subdomain,
|
|
@@ -1764,12 +1722,12 @@ function isValidDomain(value, options = {}) {
|
|
|
1764
1722
|
allowProtocol,
|
|
1765
1723
|
allowPort,
|
|
1766
1724
|
allowLocalhost
|
|
1767
|
-
}).filter(([, value]) => !
|
|
1725
|
+
}).filter(([, value]) => !require_logger.isBoolean(value));
|
|
1768
1726
|
if (invalid.length) {
|
|
1769
1727
|
const msg = invalid.map(([key, value], i) => {
|
|
1770
|
-
return joinLines(` ${i + 1}. option: "${key}"`, " expected: boolean", ` received: ${
|
|
1771
|
-
}).join(EOL);
|
|
1772
|
-
throw new TypeError(joinLines("", "> Invalid options detected in second parameter
|
|
1728
|
+
return require_formatter_ekJQF_bA.joinLines(` ${i + 1}. option: "${key}"`, " expected: boolean", ` received: ${require_logger.getPreciseType(value)} (${require_safeStableStringify.safeStableStringify(value, { keepUndefined: true })})`);
|
|
1729
|
+
}).join(require_formatter_ekJQF_bA.EOL);
|
|
1730
|
+
throw new TypeError(errorMsg(require_formatter_ekJQF_bA.joinLines("", "> Invalid options detected in second parameter:", msg)));
|
|
1773
1731
|
}
|
|
1774
1732
|
let _value = value.toLowerCase();
|
|
1775
1733
|
if (allowProtocol) try {
|
|
@@ -1826,13 +1784,8 @@ function isValidDomain(value, options = {}) {
|
|
|
1826
1784
|
if (index === labels.length - 1 && doubleDashCount !== xnDashCount) return false;
|
|
1827
1785
|
return validLabelChars.test(label) && label.length < 64 && !label.startsWith("-") && !label.endsWith("-");
|
|
1828
1786
|
});
|
|
1829
|
-
}
|
|
1830
|
-
|
|
1831
|
-
enumerable: true,
|
|
1832
|
-
get: function () {
|
|
1833
|
-
return EOL;
|
|
1834
|
-
}
|
|
1835
|
-
});
|
|
1787
|
+
};
|
|
1788
|
+
const errorMsg = (msg) => require_logger.createMessage("isValidDomain", msg);
|
|
1836
1789
|
Object.defineProperty(exports, 'isURL', {
|
|
1837
1790
|
enumerable: true,
|
|
1838
1791
|
get: function () {
|
|
@@ -1845,10 +1798,4 @@ Object.defineProperty(exports, 'isValidDomain', {
|
|
|
1845
1798
|
return isValidDomain;
|
|
1846
1799
|
}
|
|
1847
1800
|
});
|
|
1848
|
-
|
|
1849
|
-
enumerable: true,
|
|
1850
|
-
get: function () {
|
|
1851
|
-
return joinLines;
|
|
1852
|
-
}
|
|
1853
|
-
});
|
|
1854
|
-
//# sourceMappingURL=isValidDomain-ZbyeGOO9.cjs.map
|
|
1801
|
+
//# sourceMappingURL=isValidDomain-D_x7uNIu.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isValidDomain-D_x7uNIu.cjs","names":["isString","isBoolean","joinLines","getPreciseType","safeStableStringify","EOL","punycodeUtilsJS","ccTldMap","sldMap","createMessage"],"sources":["../src/predicates/is/isURL.ts","../src/predicates/is/_private/data/domain/sldMap.json","../src/predicates/is/_private/data/domain/ccTldMap.json","../src/predicates/is/isValidDomain.ts"],"sourcesContent":["/** ---------------------------------------------------------\n * * ***Type guard: `isURL`.***\n * ----------------------------------------------------------\n * **Checks if a value is an instance of the\n * **[`URL`](https://developer.mozilla.org/docs/Web/API/URL)** class.**\n *\n * ---\n * - **Behavior:**\n * - Narrows type to `URL` when true.\n * - Excludes `strings`, `plain-objects`, and `other non-URL values`.\n *\n * ---\n * @param {*} value - The value to check.\n *\n * ---\n * @returns {boolean} Returns `true` if the value is an instance of `URL`, otherwise `false`.\n *\n * ---\n * @example\n * isURL(new URL(\"https://example.com\"));\n * // ➔ true\n * isURL(\"https://example.com\");\n * // ➔ false\n */\nexport const isURL = (value: unknown): value is URL => {\n return value instanceof URL;\n};\n","","","import { joinLines, EOL } from \"@rzl-zone/build-tools/utils\";\n\nimport { createMessage } from \"@/_private/logger\";\n\nimport { punycodeUtilsJS } from \"@/urls/utils/punyCode\";\nimport { assertIsPlainObject } from \"@/assertions/objects/assertIsPlainObject\";\nimport { safeStableStringify } from \"@/conversions/stringify/safeStableStringify\";\n\nimport sldMap from \"./_private/data/domain/sldMap.json\";\nimport ccTldMap from \"./_private/data/domain/ccTldMap.json\";\n\nimport { isString } from \"./isString\";\nimport { isBoolean } from \"./isBoolean\";\n\nimport { getPreciseType } from \"../type/getPreciseType\";\n\n/** ---------------------------------------------------------\n * * ***Options for `isValidDomain` predicate.***\n * ----------------------------------------------------------\n * **Customize the behavior of domain validation.**\n */\ntype IsValidDomainOptions = {\n /** ---------------------------------------------------------\n * * ***Enable conversion of Unicode domains (IDN) to ASCII (punycode).***\n * ----------------------------------------------------------\n *\n * - Example:\n * - `\"пример.рф\"` ➔ `\"xn--e1afmkfd.xn--p1ai\"`.\n * - Allows validating Unicode domains correctly.\n * - Default: `false`.\n *\n * ---\n * @default\n * ```ts\n * false\n * ```\n */\n allowUnicode?: boolean;\n\n /** ---------------------------------------------------------\n * * ***If `true`, validates **only top-level domains (TLDs)** that are not part of any SLD/second-level domain.***\n * ----------------------------------------------------------\n *\n * - Behavior:\n * - Accepts country-code TLDs like `\"ai\"` or `\"ai.\"` ✅.\n * - Rejects common TLDs that are part of SLDs like `\"com\"` ❌.\n * - Only the final label is checked; subdomains are ignored.\n * - Default: `false`.\n *\n * ---\n * @default\n * ```ts\n * false\n * ```\n */\n topLevel?: boolean;\n\n /** ---------------------------------------------------------\n * * ***Allow or disallow subdomains.***\n * ----------------------------------------------------------\n *\n * - Example:\n * - `\"sub.example.com\"` ✅ if `subdomain` is `true`, ❌ if `false`.\n * - Wildcards and SLDs are considered when evaluating subdomains.\n * - Default: `true`.\n *\n * ---\n * @default\n * ```ts\n * true\n * ```\n */\n subdomain?: boolean;\n\n /** ---------------------------------------------------------\n * * ***Allow a wildcard `*` in the left-most label.***\n * ----------------------------------------------------------\n *\n * - Example:\n * - `\"*.example.com\"` ✅ if `wildcard` is `true`, ❌ if `false`.\n * - Wildcards are only valid in the first label and require at least one additional label.\n * - Default: `false`.\n *\n * ---\n * @default\n * ```ts\n * false\n * ```\n */\n wildcard?: boolean;\n\n /** ---------------------------------------------------------\n * * ***Allow a port after the domain.***\n * ----------------------------------------------------------\n *\n * - Example:\n * - `\"localhost:3000\"` or `\"example.com:8080\"` ✅ if `allowPort` is `true`.\n * - Validates that the port is a number between `1` and `65535`.\n * - Does not affect domain validation rules otherwise.\n * - Default: `false`.\n *\n * ---\n * @default\n * ```ts\n * false\n * ```\n */\n allowPort?: boolean;\n\n /** ---------------------------------------------------------\n * * ***Allow special domains like `localhost`.***\n * ----------------------------------------------------------\n *\n * - Example:\n * - `\"localhost\"` ✅ if `allowLocalhost` is `true`.\n * - Works with or without a port if `allowPort` is enabled.\n * - Default: `false`.\n *\n * ---\n * @default\n * ```ts\n * false\n * ```\n */\n allowLocalhost?: boolean;\n\n /** ---------------------------------------------------------\n * * ***Allow URLs with protocol (`http`/`https`) and automatically extract the hostname.***\n * ----------------------------------------------------------\n *\n * - Example:\n * - `\"https://example.com/foo/bar\"` ➔ `\"example.com\"`.\n * - The function will validate only the hostname part and ***ignore*** the `path`, `query`, and `fragment`.\n * - Default: `false`.\n *\n * ---\n * @default\n * ```ts\n * false\n * ```\n */\n allowProtocol?: boolean;\n};\n\n/** ---------------------------------------------------------\n * * ***Predicate: `isValidDomain`.***\n * ----------------------------------------------------------\n * **Validates whether a given string is a properly formatted domain name.**\n *\n * ---\n * - #### *Behavior:*\n * - Supports options for:\n * - `allowUnicode` ➔ allows internationalized domain names (IDN) with Unicode characters.\n * - `topLevel` ➔ validates **only top-level domains (TLDs)**; ignores subdomains and SLDs.\n * - `subdomain` ➔ allows or disallows subdomains.\n * - `wildcard` ➔ allows wildcard (`*`) in the left-most label.\n * - `allowPort` ➔ allows a port number after the domain (e.g., `example.com:8080`).\n * - `allowLocalhost` ➔ allows the special domain `\"localhost\"`.\n * - `allowProtocol` ➔ allows a URL with protocol (`http`/`https`) and extracts the hostname.\n * - Converts Unicode to ASCII (punycode) if `allowUnicode` is `true`.\n * - Checks label lengths (`≤63` chars), valid characters, and punycode consistency.\n * - Validates port if `allowPort` is `true` (must be 1–65535).\n * - Accepts `\"localhost\"` if `allowLocalhost` is `true`.\n * - Extracts hostname from URLs if `allowProtocol` is `true`.\n * - Rejects invalid domains, labels starting/ending with `-`, double dots, malformed TLDs, or invalid port numbers.\n * - Handles both standard domains (`example.com`), URLs with protocols (`https://example.com/foo`), and IDNs (`пример.рф`).\n *\n * ---\n * @param {*} value - The value to validate; only strings are valid domains.\n * @param {IsValidDomainOptions} [options] - Optional configuration for domain validation.\n * @param {boolean} [options.allowUnicode=false] - Enable punycode conversion for Unicode domains.\n * @param {boolean} [options.topLevel=false] - Validate only TLDs (e.g., `ai`, `uk.`); ignores SLDs like `com`.\n * @param {boolean} [options.subdomain=true] - Allow subdomains; set `false` to reject any subdomain.\n * @param {boolean} [options.wildcard=false] - Allow wildcard `*` in the left-most label (e.g., `*.example.com`).\n * @param {boolean} [options.allowPort=false] - Allow port number after domain (e.g., `:3000`); must be 1–65535.\n * @param {boolean} [options.allowLocalhost=false] - Allow special domain `\"localhost\"`.\n * @param {boolean} [options.allowProtocol=false] - Allow URLs with protocol (`http`/`https`) and extract hostname only.\n *\n * ---\n * @returns {boolean} Returns `true` if the value is a valid domain according to the rules and options; otherwise `false`.\n *\n * ---\n * @example\n * isValidDomain(\"google.com\");\n * // ➔ true\n * isValidDomain(\"пример.рф\", { allowUnicode: true });\n * // ➔ true\n * isValidDomain(\"sub.example.com\", { subdomain: false });\n * // ➔ false\n * isValidDomain(\"*.example.com\", { wildcard: true });\n * // ➔ true\n * isValidDomain(\"com\", { topLevel: true });\n * // ➔ false (common TLD rejected because it's part of SLD)\n * isValidDomain(\"ai.\", { topLevel: true });\n * // ➔ true (country-code TLD accepted)\n * isValidDomain(\"localhost\", { allowLocalhost: true });\n * // ➔ true\n * isValidDomain(\"localhost:3000\", { allowLocalhost: true, allowPort: true });\n * // ➔ true\n * isValidDomain(\"example.com:8080\", { allowPort: true });\n * // ➔ true\n * isValidDomain(\"https://example.com/foo/bar\", { allowProtocol: true });\n * // ➔ true (protocol stripped and hostname validated)\n * isValidDomain(\"invalid_domain.com\");\n * // ➔ false\n */\nexport const isValidDomain = (\n value: unknown,\n options: IsValidDomainOptions = {}\n): boolean => {\n if (!isString(value)) return false;\n\n assertIsPlainObject(options, {\n message: ({ currentType, validType }) =>\n errorMsg(\n `Second parameter (\\`options\\`) must be of type \\`${validType}\\`, but received: \\`${currentType}\\`.`\n )\n });\n\n const {\n subdomain = true,\n topLevel = false,\n wildcard = false,\n allowUnicode = false,\n allowPort = false,\n allowLocalhost = false,\n allowProtocol = false\n } = options;\n\n // Validate Options:\n const invalid = Object.entries({\n subdomain,\n topLevel,\n wildcard,\n allowUnicode,\n allowProtocol,\n allowPort,\n allowLocalhost\n }).filter(([, value]) => !isBoolean(value));\n\n if (invalid.length) {\n const msg = invalid\n .map(([key, value], i) => {\n return joinLines(\n ` ${i + 1}. option: \"${key}\"`,\n \" expected: boolean\",\n ` received: ${getPreciseType(value)} (${safeStableStringify(\n value,\n {\n keepUndefined: true\n }\n )})`\n );\n })\n .join(EOL);\n\n throw new TypeError(\n errorMsg(\n joinLines(\"\", \"> Invalid options detected in second parameter:\", msg)\n )\n );\n }\n\n // -----------------\n\n let _value = value.toLowerCase();\n\n if (allowProtocol) {\n try {\n const url = new URL(value); // use original input\n if (url.protocol !== \"http:\" && url.protocol !== \"https:\") return false; // reject non-http(s)\n if (!allowPort && url.port) return false; // reject port if allowPort=false\n _value = url.hostname.toLowerCase(); // extract only hostname\n\n // wildcard check\n const labels = _value.split(\".\");\n if (labels[0] === \"*\" && !wildcard) return false;\n } catch {\n // if parsing fails, leave _value unchanged\n }\n }\n\n if (value.endsWith(\".\")) {\n _value = _value.slice(0, _value.length - 1);\n }\n\n // Handle port\n let port: string;\n if (allowPort) {\n const portMatch = _value.match(/:(\\d{1,5})$/);\n if (portMatch) {\n port = portMatch[0];\n _value = _value.slice(0, -port.length);\n const portNum = Number(portMatch[1]);\n if (portNum < 1 || portNum > 65535) return false;\n }\n }\n\n // Allow localhost\n if (allowLocalhost && _value === \"localhost\") return true;\n\n if (allowUnicode) {\n try {\n _value = punycodeUtilsJS.toASCII(_value);\n } catch {\n return false;\n }\n }\n\n if (_value.length > 253) return false;\n\n const validChars = /^([\\u0E00-\\u0E7Fa-z0-9-._*]+)$/g;\n if (!validChars.test(_value)) return false;\n\n if (topLevel) {\n if (ccTldMap[_value.replace(/\\.$/, \"\") as keyof typeof ccTldMap]) {\n return true;\n }\n }\n\n const sldRegex = /(.*)\\.(([\\u0E00-\\u0E7Fa-z0-9]+)(\\.[a-z0-9]+))/;\n const matches = _value.match(sldRegex);\n // eslint-disable-next-line no-useless-assignment\n let tld: string | null = null;\n let labels: string[] | null = null;\n\n if (matches && matches.length > 2) {\n if (sldMap[matches[2] as keyof typeof sldMap]) {\n // eslint-disable-next-line no-useless-assignment\n tld = matches[2] || null;\n labels = matches[1]?.split(\".\") || null;\n }\n }\n\n if (!labels) {\n labels = _value.split(\".\");\n if (labels.length <= 1) return false;\n\n tld = labels.pop()!;\n const tldRegex = /^(?:xn--)?(?!^\\d+$)[\\u0E00-\\u0E7Fa-z0-9]+$/gi;\n if (!tldRegex.test(tld)) return false;\n }\n\n if (subdomain === false && labels.length > 1) return false;\n\n return labels.every((label, index) => {\n if (wildcard && index === 0 && label === \"*\" && labels.length > 1) {\n return true;\n }\n\n let validLabelChars = /^([\\u0E00-\\u0E7Fa-zA-Z0-9-_]+)$/g;\n if (index === labels.length - 1) {\n validLabelChars = /^([\\u0E00-\\u0E7Fa-zA-Z0-9-]+)$/g;\n }\n\n const doubleDashCount = (label.match(/--(--)?/g) || []).length;\n const xnDashCount = (label.match(/xn--/g) || []).length;\n if (index === labels.length - 1 && doubleDashCount !== xnDashCount) {\n return false;\n }\n\n return (\n validLabelChars.test(label) &&\n label.length < 64 &&\n !label.startsWith(\"-\") &&\n !label.endsWith(\"-\")\n );\n });\n};\n\n/**\n * @internal ***`Not part of the public API.`***\n */\nconst errorMsg = (msg: string) => createMessage(\"isValidDomain\", msg);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwBA,MAAa,SAAS,UAAi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