@rzl-zone/utils-js 3.12.0 → 3.12.1-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{LICENSE.md → LICENSE} +3 -3
- package/README.md +69 -96
- package/dist/.references/index.d.cts +25 -0
- package/dist/.references/index.d.ts +25 -0
- package/dist/assertIsArray-DJXkjHZs.cjs +26 -0
- package/dist/assertIsArray-DJXkjHZs.cjs.map +1 -0
- package/dist/assertIsArray-bTA3XLjq.js +20 -0
- package/dist/assertIsArray-bTA3XLjq.js.map +1 -0
- package/dist/assertIsBoolean-C8WEXVr2.cjs +1283 -0
- package/dist/assertIsBoolean-C8WEXVr2.cjs.map +1 -0
- package/dist/assertIsBoolean-DR1SaXPD.js +1073 -0
- package/dist/assertIsBoolean-DR1SaXPD.js.map +1 -0
- package/dist/assertIsString-BiHQSrB2.cjs +26 -0
- package/dist/assertIsString-BiHQSrB2.cjs.map +1 -0
- package/dist/assertIsString-CEB07_83.js +20 -0
- package/dist/assertIsString-CEB07_83.js.map +1 -0
- package/dist/assertions/index.cjs +37 -40
- package/dist/assertions/index.cjs.map +1 -0
- package/dist/assertions/index.d.cts +12 -0
- package/dist/assertions/index.d.ts +10 -824
- package/dist/assertions/index.js +30 -13
- package/dist/assertions/index.js.map +1 -0
- package/dist/conversions/index.cjs +34 -103
- package/dist/conversions/index.d.cts +12 -0
- package/dist/conversions/index.d.ts +10 -1791
- package/dist/conversions/index.js +14 -24
- package/dist/conversions-BNIh_tCH.js +380 -0
- package/dist/conversions-BNIh_tCH.js.map +1 -0
- package/dist/conversions-D_Kh0a_C.cjs +446 -0
- package/dist/conversions-D_Kh0a_C.cjs.map +1 -0
- package/dist/events/index.cjs +55 -31
- package/dist/events/index.cjs.map +1 -0
- package/dist/events/index.d.cts +176 -0
- package/dist/events/index.d.ts +164 -166
- package/dist/events/index.js +50 -12
- package/dist/events/index.js.map +1 -0
- package/dist/formatEnvPort-B3OLxQk9.cjs +171 -0
- package/dist/formatEnvPort-B3OLxQk9.cjs.map +1 -0
- package/dist/formatEnvPort-ByFVLjSV.js +159 -0
- package/dist/formatEnvPort-ByFVLjSV.js.map +1 -0
- package/dist/formatters/index.cjs +21 -61
- package/dist/formatters/index.d.cts +12 -0
- package/dist/formatters/index.d.ts +10 -2152
- package/dist/formatters/index.js +10 -18
- package/dist/formatters--1m_vpE8.js +369 -0
- package/dist/formatters--1m_vpE8.js.map +1 -0
- package/dist/formatters-Cbij0XLU.cjs +429 -0
- package/dist/formatters-Cbij0XLU.cjs.map +1 -0
- package/dist/generators/index.cjs +165 -41
- package/dist/generators/index.cjs.map +1 -0
- package/dist/generators/index.d.cts +12 -0
- package/dist/generators/index.d.ts +10 -338
- package/dist/generators/index.js +158 -14
- package/dist/generators/index.js.map +1 -0
- package/dist/index-59zbLcPr.d.ts +340 -0
- package/dist/index-B6tawc8L.d.cts +1716 -0
- package/dist/index-C267akkJ.d.ts +2158 -0
- package/dist/index-CeBC2Vvl.d.cts +2361 -0
- package/dist/index-CgRDTI6f.d.ts +822 -0
- package/dist/index-CoiUBVmr.d.ts +720 -0
- package/dist/index-D4fcasfZ.d.cts +720 -0
- package/dist/index-DDrSQKIc.d.ts +1716 -0
- package/dist/index-DsGxO31H.d.cts +765 -0
- package/dist/index-Hg1qJkjl.d.ts +765 -0
- package/dist/index-Qm3iFwd0.d.cts +2158 -0
- package/dist/index-UPp94Agr.d.ts +2361 -0
- package/dist/index-gBA_8SuF.d.cts +340 -0
- package/dist/index-jyDqzicx.d.cts +822 -0
- package/dist/isBigInt-C4krUeAw.cjs +20 -0
- package/dist/isBigInt-C4krUeAw.cjs.map +1 -0
- package/dist/isBigInt-DKe0M6hp.js +14 -0
- package/dist/isBigInt-DKe0M6hp.js.map +1 -0
- package/dist/isEmptyObject-DCipFwxJ.js +25 -0
- package/dist/isEmptyObject-DCipFwxJ.js.map +1 -0
- package/dist/isEmptyObject-ZkSwRC_D.cjs +37 -0
- package/dist/isEmptyObject-ZkSwRC_D.cjs.map +1 -0
- package/dist/isEmptyString-BXzKAC2j.js +15 -0
- package/dist/isEmptyString-BXzKAC2j.js.map +1 -0
- package/dist/isEmptyString-UiiUsSQj.cjs +21 -0
- package/dist/isEmptyString-UiiUsSQj.cjs.map +1 -0
- package/dist/isEmptyValue-BQzcjVaL.cjs +30 -0
- package/dist/isEmptyValue-BQzcjVaL.cjs.map +1 -0
- package/dist/isEmptyValue-jqOr7OHD.js +24 -0
- package/dist/isEmptyValue-jqOr7OHD.js.map +1 -0
- package/dist/isEqual-BX49cF9m.js +87 -0
- package/dist/isEqual-BX49cF9m.js.map +1 -0
- package/dist/isEqual-BvumA3RA.cjs +111 -0
- package/dist/isEqual-BvumA3RA.cjs.map +1 -0
- package/dist/isFinite-BCnaDpod.js +15 -0
- package/dist/isFinite-BCnaDpod.js.map +1 -0
- package/dist/isFinite-D24ZaE6c.cjs +21 -0
- package/dist/isFinite-D24ZaE6c.cjs.map +1 -0
- package/dist/isInteger-Caeuz0rB.cjs +20 -0
- package/dist/isInteger-Caeuz0rB.cjs.map +1 -0
- package/dist/isInteger-naMbJsxJ.js +14 -0
- package/dist/isInteger-naMbJsxJ.js.map +1 -0
- package/dist/isPlainObject-BF-2-phb.d.cts +339 -0
- package/dist/isPlainObject-DxNDL8XU.d.ts +339 -0
- package/dist/isServer-BJHVnixd.cjs +20 -0
- package/dist/isServer-BJHVnixd.cjs.map +1 -0
- package/dist/isServer-Da3o3XSs.js +14 -0
- package/dist/isServer-Da3o3XSs.js.map +1 -0
- package/dist/isTypedArray-DuNA8tK6.js +31 -0
- package/dist/isTypedArray-DuNA8tK6.js.map +1 -0
- package/dist/isTypedArray-TJptiw2b.cjs +43 -0
- package/dist/isTypedArray-TJptiw2b.cjs.map +1 -0
- package/dist/isURL-C-kSk6KJ.js +14 -0
- package/dist/isURL-C-kSk6KJ.js.map +1 -0
- package/dist/isURL-DeUPO_oR.cjs +20 -0
- package/dist/isURL-DeUPO_oR.cjs.map +1 -0
- package/dist/isValidDomain-BB9IGhJs.cjs +1845 -0
- package/dist/isValidDomain-BB9IGhJs.cjs.map +1 -0
- package/dist/isValidDomain-DoE98yhJ.js +1827 -0
- package/dist/isValidDomain-DoE98yhJ.js.map +1 -0
- package/dist/next/index.cjs +119 -214
- package/dist/next/index.cjs.map +1 -0
- package/dist/next/index.d.cts +220 -0
- package/dist/next/index.d.ts +203 -214
- package/dist/next/index.js +117 -212
- package/dist/next/index.js.map +1 -0
- package/dist/next/server/index.cjs +25 -40
- package/dist/next/server/index.cjs.map +1 -0
- package/dist/next/server/index.d.cts +39 -0
- package/dist/next/server/index.d.ts +34 -35
- package/dist/next/server/index.js +23 -38
- package/dist/next/server/index.js.map +1 -0
- package/dist/noop-B13_ii35.cjs +18 -0
- package/dist/noop-B13_ii35.cjs.map +1 -0
- package/dist/noop-ubqAIbHD.js +12 -0
- package/dist/noop-ubqAIbHD.js.map +1 -0
- package/dist/normalizeSpaces-Bg2IZW7W.js +23 -0
- package/dist/normalizeSpaces-Bg2IZW7W.js.map +1 -0
- package/dist/normalizeSpaces-ZXnR4Qzp.cjs +29 -0
- package/dist/normalizeSpaces-ZXnR4Qzp.cjs.map +1 -0
- package/dist/normalizeString-BDdkaXui.js +15 -0
- package/dist/normalizeString-BDdkaXui.js.map +1 -0
- package/dist/normalizeString-BE6ELqEb.cjs +21 -0
- package/dist/normalizeString-BE6ELqEb.cjs.map +1 -0
- package/dist/operations/index.cjs +65 -32
- package/dist/operations/index.cjs.map +1 -0
- package/dist/operations/index.d.cts +139 -0
- package/dist/operations/index.d.ts +129 -134
- package/dist/operations/index.js +61 -17
- package/dist/operations/index.js.map +1 -0
- package/dist/parsers/index.cjs +12 -19
- package/dist/parsers/index.d.cts +239 -0
- package/dist/parsers/index.d.ts +234 -235
- package/dist/parsers/index.js +10 -12
- package/dist/parsers-BSBPgvsq.js +643 -0
- package/dist/parsers-BSBPgvsq.js.map +1 -0
- package/dist/parsers-OqDeffqc.cjs +649 -0
- package/dist/parsers-OqDeffqc.cjs.map +1 -0
- package/dist/parsing-Cao8b358.js +50 -0
- package/dist/parsing-Cao8b358.js.map +1 -0
- package/dist/parsing-DOGSCH6N.cjs +56 -0
- package/dist/parsing-DOGSCH6N.cjs.map +1 -0
- package/dist/predicates/index.cjs +91 -296
- package/dist/predicates/index.d.cts +13 -0
- package/dist/predicates/index.d.ts +12 -2482
- package/dist/predicates/index.js +23 -25
- package/dist/predicates-Bj6meyXV.js +256 -0
- package/dist/predicates-Bj6meyXV.js.map +1 -0
- package/dist/predicates-D0ubqgqy.cjs +412 -0
- package/dist/predicates-D0ubqgqy.cjs.map +1 -0
- package/dist/promises/index.cjs +76 -24
- package/dist/promises/index.cjs.map +1 -0
- package/dist/promises/index.d.cts +123 -0
- package/dist/promises/index.d.ts +116 -119
- package/dist/promises/index.js +73 -13
- package/dist/promises/index.js.map +1 -0
- package/dist/punyCode-8SrbMWfM.js +179 -0
- package/dist/punyCode-8SrbMWfM.js.map +1 -0
- package/dist/punyCode-D-Qu6nj6.cjs +185 -0
- package/dist/punyCode-D-Qu6nj6.cjs.map +1 -0
- package/dist/removeSpaces-Bmc5DX4F.js +19 -0
- package/dist/removeSpaces-Bmc5DX4F.js.map +1 -0
- package/dist/removeSpaces-CWIvhZHg.cjs +25 -0
- package/dist/removeSpaces-CWIvhZHg.cjs.map +1 -0
- package/dist/rzl-utils.global.js +20 -9
- package/dist/safeJsonParse-BP38mwlj.js +184 -0
- package/dist/safeJsonParse-BP38mwlj.js.map +1 -0
- package/dist/safeJsonParse-Sms2CJf4.cjs +208 -0
- package/dist/safeJsonParse-Sms2CJf4.cjs.map +1 -0
- package/dist/safeStableStringify-CJtP89qn.cjs +106 -0
- package/dist/safeStableStringify-CJtP89qn.cjs.map +1 -0
- package/dist/safeStableStringify-CXOZ9Ub8.js +88 -0
- package/dist/safeStableStringify-CXOZ9Ub8.js.map +1 -0
- package/dist/strings/index.cjs +79 -81
- package/dist/strings/index.cjs.map +1 -0
- package/dist/strings/index.d.cts +12 -0
- package/dist/strings/index.d.ts +10 -775
- package/dist/strings/index.js +62 -14
- package/dist/strings/index.js.map +1 -0
- package/dist/tailwind/index.cjs +19 -47
- package/dist/tailwind/index.d.cts +12 -0
- package/dist/tailwind/index.d.ts +11 -712
- package/dist/tailwind/index.js +10 -12
- package/dist/tailwind-B2ssevxq.js +199 -0
- package/dist/tailwind-B2ssevxq.js.map +1 -0
- package/dist/tailwind-CHIx9uxu.cjs +247 -0
- package/dist/tailwind-CHIx9uxu.cjs.map +1 -0
- package/dist/toStringArrayUnRecursive-C4zYCja7.cjs +51 -0
- package/dist/toStringArrayUnRecursive-C4zYCja7.cjs.map +1 -0
- package/dist/toStringArrayUnRecursive-DJGtPsFb.js +39 -0
- package/dist/toStringArrayUnRecursive-DJGtPsFb.js.map +1 -0
- package/dist/urls/index.cjs +130 -57
- package/dist/urls/index.cjs.map +1 -0
- package/dist/urls/index.d.cts +737 -0
- package/dist/urls/index.d.ts +699 -708
- package/dist/urls/index.js +122 -26
- package/dist/urls/index.js.map +1 -0
- package/package.json +203 -194
- package/dist/chunk-2AFQ33D3.cjs +0 -64
- package/dist/chunk-2CYDJVGM.js +0 -246
- package/dist/chunk-2MW4JDQ2.cjs +0 -598
- package/dist/chunk-2VTDXC3N.cjs +0 -1825
- package/dist/chunk-44XX2P34.js +0 -209
- package/dist/chunk-4YLBKLGS.cjs +0 -18
- package/dist/chunk-566CXQW7.cjs +0 -560
- package/dist/chunk-57EPKYID.cjs +0 -397
- package/dist/chunk-5MGEC3YG.js +0 -63
- package/dist/chunk-6EF52423.cjs +0 -249
- package/dist/chunk-6SCOKU3S.js +0 -109
- package/dist/chunk-6VUXD3CF.js +0 -119
- package/dist/chunk-7B76BSNK.cjs +0 -118
- package/dist/chunk-7Y6I2DSU.cjs +0 -101
- package/dist/chunk-A7S7E2EE.cjs +0 -308
- package/dist/chunk-AJZ6PMMZ.js +0 -16
- package/dist/chunk-AXGBL2IO.cjs +0 -251
- package/dist/chunk-B4TC6FBV.cjs +0 -678
- package/dist/chunk-BAV5T2E3.cjs +0 -15
- package/dist/chunk-BKIJBNIE.js +0 -21
- package/dist/chunk-BNIMTFK5.js +0 -59
- package/dist/chunk-BXW7YXB7.js +0 -1823
- package/dist/chunk-CFYZC4S6.js +0 -53
- package/dist/chunk-CSG4SCL3.js +0 -1587
- package/dist/chunk-CWQW7AKK.js +0 -676
- package/dist/chunk-DVMHRLKP.cjs +0 -16
- package/dist/chunk-EN7LVZBZ.js +0 -548
- package/dist/chunk-EV4Y7HCY.cjs +0 -26
- package/dist/chunk-F66VDYIZ.cjs +0 -18
- package/dist/chunk-FLJX37EL.cjs +0 -30
- package/dist/chunk-GKC3UDMC.cjs +0 -1623
- package/dist/chunk-H65I3GRZ.cjs +0 -106
- package/dist/chunk-HHYWB7VZ.js +0 -24
- package/dist/chunk-HNGGISFL.cjs +0 -65
- package/dist/chunk-HNSQAVSZ.cjs +0 -35
- package/dist/chunk-HSP6IWZK.js +0 -17
- package/dist/chunk-IDZS7J6T.js +0 -242
- package/dist/chunk-JS6R55VL.js +0 -302
- package/dist/chunk-JZVT5FK7.js +0 -232
- package/dist/chunk-KHO2SBNA.cjs +0 -16
- package/dist/chunk-KIDJCMNJ.js +0 -33
- package/dist/chunk-KOLEURVT.cjs +0 -38
- package/dist/chunk-L4V53MQK.cjs +0 -269
- package/dist/chunk-L5RDAVVH.js +0 -14
- package/dist/chunk-NODTV4F3.js +0 -16
- package/dist/chunk-NYK5K3V2.cjs +0 -211
- package/dist/chunk-ODUO3RTL.cjs +0 -113
- package/dist/chunk-ONZFBJVW.js +0 -14
- package/dist/chunk-PFXCTE37.js +0 -28
- package/dist/chunk-PPST7QAQ.js +0 -587
- package/dist/chunk-Q5IMYDFL.cjs +0 -33
- package/dist/chunk-QFFBIOJ4.js +0 -31
- package/dist/chunk-QNKGP5DY.js +0 -14
- package/dist/chunk-RRQHMOPE.cjs +0 -19
- package/dist/chunk-RU5OSRBU.js +0 -95
- package/dist/chunk-SDMPEJ4F.js +0 -35
- package/dist/chunk-SYNL5IKP.js +0 -115
- package/dist/chunk-TCDOWZQE.js +0 -16
- package/dist/chunk-TQPGXGKB.cjs +0 -123
- package/dist/chunk-TULOI4GL.js +0 -370
- package/dist/chunk-UBHCP4N5.cjs +0 -36
- package/dist/chunk-UCHF3M34.cjs +0 -56
- package/dist/chunk-UDA26MCU.cjs +0 -16
- package/dist/chunk-V3C4FYZL.cjs +0 -18
- package/dist/chunk-VAAHZFBF.js +0 -32
- package/dist/chunk-VJDDGRIK.cjs +0 -16
- package/dist/chunk-WVSPXFTY.js +0 -14
- package/dist/chunk-WYP76WXB.js +0 -101
- package/dist/chunk-YDE4ZBB7.cjs +0 -237
- package/dist/chunk-YKQEOO7C.cjs +0 -23
- package/dist/chunk-YSZC56SZ.js +0 -264
- package/dist/chunk-YWHHVDT4.js +0 -13
- package/dist/index.d.ts +0 -24
- package/dist/isPlainObject-DTJVV2Kf.d.ts +0 -536
package/{LICENSE.md → LICENSE}
RENAMED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c)
|
|
3
|
+
Copyright (c) 2026 Rizalvin Dwiky.
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the
|
|
6
|
+
of this software and associated documentation files (the “Software”), to deal
|
|
7
7
|
in the Software without restriction, including without limitation the rights
|
|
8
8
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
9
|
copies of the Software, and to permit persons to whom the Software is
|
|
@@ -12,7 +12,7 @@ furnished to do so, subject to the following conditions:
|
|
|
12
12
|
The above copyright notice and this permission notice shall be included in all
|
|
13
13
|
copies or substantial portions of the Software.
|
|
14
14
|
|
|
15
|
-
THE SOFTWARE IS PROVIDED
|
|
15
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
16
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
17
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
18
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
package/README.md
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
<div align="center" style="display: flex; flex-direction: column; align-items: center;gap: 0rem">
|
|
2
|
-
<a target="_blank" rel="noopener noreferrer" href="https://raw.githubusercontent.com/rzl-zone/
|
|
3
|
-
<img src="https://raw.githubusercontent.com/rzl-zone/
|
|
2
|
+
<a target="_blank" rel="noopener noreferrer" href="https://raw.githubusercontent.com/rzl-zone/rzl-zone/main/logo-circle.png">
|
|
3
|
+
<img src="https://raw.githubusercontent.com/rzl-zone/rzl-zone/main/logo-circle.png" align="middle" alt="RzlZone Logo" width="110" style="max-width: 100%;" />
|
|
4
4
|
</a>
|
|
5
5
|
</div>
|
|
6
6
|
|
|
7
|
-
<h1 align="center"><strong>
|
|
7
|
+
<h1 align="center"><strong>Utils JS</strong></h1>
|
|
8
8
|
|
|
9
9
|
<p align="center">
|
|
10
10
|
<i>
|
|
11
|
-
A lightweight, modern TypeScript utility library for Node.js & browser (via bundlers like <a href="https://webpack.js.org"><code>Webpack</code></a>, <a href="https://vercel.com/blog/turbopack"><code>Turbopack</code></a>,
|
|
11
|
+
A lightweight, modern TypeScript utility library for Node.js & browser (via bundlers like <a href="https://webpack.js.org/"><code>Webpack</code></a>, <a href="https://vercel.com/blog/turbopack/"><code>Turbopack</code></a>, <a href="https://rollupjs.org/"><code>Rollup</code></a>, <a href="https://esbuild.github.io/"><code>esbuild</code></a>, and higher-level tools like <a href="https://vite.dev/"><code>Vite</code></a>, <a href="https://tsup.egoist.dev/"><code>tsup</code></a> and <a href="https://tsdown.dev/"><code>tsdown</code></a>).
|
|
12
12
|
</i><br/>
|
|
13
|
-
<i>
|
|
13
|
+
<i>It provides reusable helpers to simplify everyday JavaScript and TypeScript tasks projects.</i><br/>
|
|
14
14
|
<strong><i>Built with ❤️ by <a href="https://github.com/rzl-zone" target="_blank" rel="nofollow noreferrer noopener">@rzl-zone</a>.</i></strong>
|
|
15
15
|
</p>
|
|
16
16
|
|
|
@@ -28,16 +28,16 @@
|
|
|
28
28
|
<a href="https://nodejs.org/en/" target="_blank" rel="nofollow noreferrer noopener">
|
|
29
29
|
<img src="https://img.shields.io/badge/Node.js-18.18.0%2B-green.svg?logo=node.js&color=339933&style=flat-rounded" alt="Node.js" />
|
|
30
30
|
</a>
|
|
31
|
-
<a href="https://github.com/rzl-zone/
|
|
31
|
+
<a href="https://github.com/rzl-zone/rzl-zone/blob/main/CONTRIBUTING.md" target="_blank" rel="nofollow noreferrer noopener">
|
|
32
32
|
<img src="https://img.shields.io/badge/PRs-Welcome-brightgreen.svg?color=28A745" alt="PRs Welcome" />
|
|
33
33
|
</a>
|
|
34
|
-
<a href="https://github.com/rzl-zone/
|
|
34
|
+
<a href="https://github.com/rzl-zone/rzl-zone/blob/main/LICENSE" target="_blank" rel="nofollow noreferrer noopener">
|
|
35
35
|
<img src="https://img.shields.io/badge/License-MIT-blue.svg?color=3DA639" alt="GitHub license" />
|
|
36
36
|
</a>
|
|
37
|
-
<a href="https://github.com/rzl-zone/utils-js" target="_blank" rel="nofollow noreferrer noopener">
|
|
37
|
+
<a href="https://github.com/rzl-zone/rzl-zone/tree/main/packages/utils-js" target="_blank" rel="nofollow noreferrer noopener">
|
|
38
38
|
<img src="https://img.shields.io/badge/Repo-on%20GitHub-181717?logo=github" alt="GitHub" />
|
|
39
39
|
</a>
|
|
40
|
-
<a href="https://github.com/
|
|
40
|
+
<a href="https://github.com/rzl-zone/rzl-zone" target="_blank" rel="nofollow noreferrer noopener">
|
|
41
41
|
<img src="https://img.shields.io/badge/Org-rzl--zone-24292e?logo=github&style=flat-rounded" alt="Repo on GitHub" />
|
|
42
42
|
</a>
|
|
43
43
|
</p>
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
- **Works with:**
|
|
76
76
|
- ✅ Node.js (18.18.0+) - ***Without NextJS***.
|
|
77
77
|
- ✅ Node.js (20.9.0, or higher depending on NextJS version) - ***With NextJS***.
|
|
78
|
-
- ✅ Modern browsers (via bundlers
|
|
78
|
+
- ✅ Modern browsers (via **ESM-compatible** bundlers such as [`Webpack`](https://webpack.js.org/), [`Turbopack`](https://vercel.com/blog/turbopack), [`Rollup`](https://rollupjs.org/), [`esbuild`](https://esbuild.github.io/), and higher-level tools like [`Vite`](https://vite.dev/), [`tsup`](https://tsup.egoist.dev/), and [`tsdown`](https://tsdown.dev/)).
|
|
79
79
|
|
|
80
80
|
- **TypeScript Build Info:**
|
|
81
81
|
- Target: `ES2022`.
|
|
@@ -130,7 +130,7 @@ pnpm add @rzl-zone/utils-js@latest
|
|
|
130
130
|
|
|
131
131
|
✅ Safe to use in both Next.js pages & API routes.
|
|
132
132
|
|
|
133
|
-
[**Read More Docs**](/docs/next-js/global.md#docs-sub-main--title)
|
|
133
|
+
[**Read More Docs**](https://github.com/rzl-zone/rzl-zone/blob/main/packages/utils-js/docs/next-js/global.md#docs-sub-main--title)
|
|
134
134
|
|
|
135
135
|
---
|
|
136
136
|
|
|
@@ -139,7 +139,7 @@ pnpm add @rzl-zone/utils-js@latest
|
|
|
139
139
|
|
|
140
140
|
> ⚠️ Will throw Error if used outside a ***Next.js* server environment**.
|
|
141
141
|
|
|
142
|
-
[**Read More Docs**](/docs/next-js/server-only.md#docs-sub-main--title)
|
|
142
|
+
[**Read More Docs**](https://github.com/rzl-zone/rzl-zone/blob/main/packages/utils-js/docs/next-js/server-only.md#docs-sub-main--title)
|
|
143
143
|
|
|
144
144
|
---
|
|
145
145
|
|
|
@@ -201,7 +201,7 @@ pnpm add @rzl-zone/utils-js@latest
|
|
|
201
201
|
> - Category utils of `tailwind`, `next`, `next/server`.
|
|
202
202
|
> - Server-only features (like Next.js helpers) will **not** be available.
|
|
203
203
|
> - The global object provided is `RzlUtilsJs`.
|
|
204
|
-
> - The CDN bundle is **~
|
|
204
|
+
> - The CDN bundle is **~370KB+ minified**, for production, consider using bundlers or npm packages for smaller size and tree-shaking.
|
|
205
205
|
|
|
206
206
|
---
|
|
207
207
|
|
|
@@ -211,104 +211,77 @@ pnpm add @rzl-zone/utils-js@latest
|
|
|
211
211
|
</strong>
|
|
212
212
|
</h3>
|
|
213
213
|
|
|
214
|
-
|
|
214
|
+
Improve TypeScript editor import suggestions for `@rzl-zone/utils-js`, so all functions, types, and modules appear instantly when triggering autocomplete — press `Ctrl+Space` (**Windows/Linux**), `⌘+Space` (**macOS**), or your editor’s autocomplete shortcut.
|
|
215
215
|
|
|
216
|
-
-
|
|
217
|
-
|
|
218
|
-
- Make sure the package is installed:
|
|
216
|
+
This works across modern TypeScript-supported editors (e.g., `VSCode`, `WebStorm`, `Vim extensions`, `NeoVim LSP`, `Cursor`) without requiring triple-slash references — the package is fully indexed automatically through your editor’s TypeScript language service, follow steps:
|
|
219
217
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
# or
|
|
223
|
-
yarn add @rzl-zone/utils-js@latest
|
|
224
|
-
# or
|
|
225
|
-
pnpm add @rzl-zone/utils-js@latest
|
|
226
|
-
```
|
|
218
|
+
- 1️⃣ **Install @rzl-zone/utils-js.**
|
|
219
|
+
- Make sure the package is installed, see [**Installation Guide**](#installation).
|
|
227
220
|
|
|
228
221
|
- 2️⃣ **Create a types folder.**
|
|
229
|
-
|
|
230
222
|
- Inside your project root, make a folder called `types`:
|
|
231
223
|
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
224
|
+
```pgsql
|
|
225
|
+
project-root/
|
|
226
|
+
├─ src/
|
|
227
|
+
├─ types/
|
|
228
|
+
│ └─ index.d.ts
|
|
229
|
+
├─ tsconfig.json
|
|
230
|
+
└─ jsconfig.json
|
|
231
|
+
```
|
|
240
232
|
|
|
241
233
|
- 3️⃣ **Add the global reference file.**
|
|
242
|
-
|
|
243
234
|
- Create `types/index.d.ts` with this content:
|
|
244
235
|
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
236
|
+
```ts
|
|
237
|
+
/// <reference types="@rzl-zone/utils-js/.references" />
|
|
238
|
+
```
|
|
248
239
|
|
|
249
|
-
|
|
250
|
-
- You can add more references here if needed, for example:
|
|
240
|
+
- You can add more references here if needed, for example:
|
|
251
241
|
|
|
252
|
-
|
|
253
|
-
|
|
242
|
+
```ts
|
|
243
|
+
/// <reference types="@rzl-zone/utils-js/.references" />
|
|
254
244
|
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
245
|
+
// eg more references (if needed):
|
|
246
|
+
/// <reference types="node" />
|
|
247
|
+
/// <reference types="react" />
|
|
248
|
+
```
|
|
259
249
|
|
|
260
250
|
- 4️⃣ **Update tsconfig.json.**
|
|
251
|
+
- Make sure add `types` folder to `"include"`, so **TypeScript** automatically picks up your types folder:
|
|
261
252
|
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
"compilerOptions": {
|
|
268
|
-
"strict": true,
|
|
269
|
-
"typeRoots": [
|
|
270
|
-
"./types",
|
|
271
|
-
"./node_modules/@types"
|
|
272
|
-
],
|
|
273
|
-
// other your config...
|
|
274
|
-
},
|
|
275
|
-
"include": [
|
|
276
|
-
"src",
|
|
277
|
-
"types"
|
|
278
|
-
],
|
|
253
|
+
```jsonc
|
|
254
|
+
// tsconfig.json
|
|
255
|
+
{
|
|
256
|
+
"compilerOptions": {
|
|
257
|
+
"strict": true,
|
|
279
258
|
// other your config...
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
259
|
+
},
|
|
260
|
+
"include": ["src", "types"]
|
|
261
|
+
// other your config...
|
|
262
|
+
}
|
|
263
|
+
```
|
|
285
264
|
|
|
286
265
|
- 5️⃣ **Update jsconfig.json (for JavaScript projects).**
|
|
287
|
-
|
|
288
266
|
- If you also work with JS, do the same:
|
|
289
267
|
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
"typeRoots": [
|
|
296
|
-
"./types",
|
|
297
|
-
"./node_modules/@types"
|
|
298
|
-
],
|
|
299
|
-
// other your config...
|
|
300
|
-
},
|
|
301
|
-
"include": [
|
|
302
|
-
"src",
|
|
303
|
-
"types"
|
|
304
|
-
],
|
|
268
|
+
```jsonc
|
|
269
|
+
// jsconfig.json
|
|
270
|
+
{
|
|
271
|
+
"compilerOptions": {
|
|
272
|
+
"checkJs": true, // Optional, enables type checking
|
|
305
273
|
// other your config...
|
|
306
|
-
}
|
|
307
|
-
|
|
274
|
+
},
|
|
275
|
+
"include": ["src", "types"]
|
|
276
|
+
// other your config...
|
|
277
|
+
}
|
|
278
|
+
```
|
|
308
279
|
|
|
309
|
-
|
|
280
|
+
> ℹ️ ***Tip:*** *For JS projects, consider adding `"checkJs": true` for better IntelliSense.*
|
|
310
281
|
|
|
311
|
-
|
|
282
|
+
- 6️⃣ **Restart your editor/IDE.**
|
|
283
|
+
- This forces your TypeScript language service to re-index the package.
|
|
284
|
+
- After restart, **all functions, types, and modules from `@rzl-zone/utils-js` will appear instantly in autocomplete**.
|
|
312
285
|
|
|
313
286
|
---
|
|
314
287
|
|
|
@@ -336,13 +309,13 @@ console.log(isServer());
|
|
|
336
309
|
|
|
337
310
|
<h2 id="changelog">📝 <strong>Changelog</strong></h2>
|
|
338
311
|
|
|
339
|
-
**See [CHANGELOG](CHANGELOG.md).**
|
|
312
|
+
**See [CHANGELOG](https://github.com/rzl-zone/rzl-zone/blob/main/packages/utils-js/CHANGELOG.md).**
|
|
340
313
|
|
|
341
314
|
---
|
|
342
315
|
|
|
343
316
|
<h2 id="contributing">🤝 <strong>Contributing</strong></h2>
|
|
344
317
|
|
|
345
|
-
**See [CONTRIBUTING](CONTRIBUTING.md).**
|
|
318
|
+
**See [CONTRIBUTING](https://github.com/rzl-zone/rzl-zone/blob/main/CONTRIBUTING.md).**
|
|
346
319
|
|
|
347
320
|
---
|
|
348
321
|
|
|
@@ -354,20 +327,20 @@ console.log(isServer());
|
|
|
354
327
|
|
|
355
328
|
<h2 id="credits">🙌 <strong>Credits</strong></h2>
|
|
356
329
|
|
|
357
|
-
**- [Rzl App](https://github.com/rzl-app)
|
|
358
|
-
**- [All Contributors](
|
|
330
|
+
**- [Rzl App](https://github.com/rzl-app).**
|
|
331
|
+
**- [All Contributors](https://github.com/rzl-zone/rzl-zone/graphs/contributors).**
|
|
359
332
|
|
|
360
333
|
---
|
|
361
334
|
|
|
362
335
|
<h2 id="license">📜 <strong>License</strong></h2>
|
|
363
336
|
|
|
364
|
-
**The MIT License (MIT).**
|
|
365
|
-
*Please see **[License File](LICENSE
|
|
337
|
+
**The MIT License (MIT).**
|
|
338
|
+
*Please see **[License File](https://github.com/rzl-zone/rzl-zone/blob/main/LICENSE)** for more information.*
|
|
366
339
|
|
|
367
340
|
---
|
|
368
341
|
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
342
|
+
✅ **Enjoy using `@rzl-zone/utils-js`?**
|
|
343
|
+
*Star the monorepo [⭐](https://github.com/rzl-zone/rzl-zone) and share it with other JavaScript developers!*
|
|
344
|
+
📦 Explore other packages under [`@rzl-zone`](https://github.com/rzl-zone/rzl-zone)
|
|
372
345
|
|
|
373
346
|
---
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* ========================================================================
|
|
3
|
+
* @rzl-zone/utils-js
|
|
4
|
+
* ------------------------------------------------------------------------
|
|
5
|
+
* Version: `3.12.1-beta.1`
|
|
6
|
+
* Author: `Rizalvin Dwiky <rizalvindwiky@gmail.com>`
|
|
7
|
+
* Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/utils-js`
|
|
8
|
+
* ========================================================================
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
//! References Paths:
|
|
12
|
+
/// <reference path="../assertions/index.d.cts" />
|
|
13
|
+
/// <reference path="../conversions/index.d.cts" />
|
|
14
|
+
/// <reference path="../events/index.d.cts" />
|
|
15
|
+
/// <reference path="../formatters/index.d.cts" />
|
|
16
|
+
/// <reference path="../generators/index.d.cts" />
|
|
17
|
+
/// <reference path="../next/index.d.cts" />
|
|
18
|
+
/// <reference path="../next/server/index.d.cts" />
|
|
19
|
+
/// <reference path="../operations/index.d.cts" />
|
|
20
|
+
/// <reference path="../parsers/index.d.cts" />
|
|
21
|
+
/// <reference path="../predicates/index.d.cts" />
|
|
22
|
+
/// <reference path="../promises/index.d.cts" />
|
|
23
|
+
/// <reference path="../strings/index.d.cts" />
|
|
24
|
+
/// <reference path="../tailwind/index.d.cts" />
|
|
25
|
+
/// <reference path="../urls/index.d.cts" />
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* ========================================================================
|
|
3
|
+
* @rzl-zone/utils-js
|
|
4
|
+
* ------------------------------------------------------------------------
|
|
5
|
+
* Version: `3.12.1-beta.1`
|
|
6
|
+
* Author: `Rizalvin Dwiky <rizalvindwiky@gmail.com>`
|
|
7
|
+
* Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/utils-js`
|
|
8
|
+
* ========================================================================
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
//! References Paths:
|
|
12
|
+
/// <reference path="../assertions/index.d.ts" />
|
|
13
|
+
/// <reference path="../conversions/index.d.ts" />
|
|
14
|
+
/// <reference path="../events/index.d.ts" />
|
|
15
|
+
/// <reference path="../formatters/index.d.ts" />
|
|
16
|
+
/// <reference path="../generators/index.d.ts" />
|
|
17
|
+
/// <reference path="../next/index.d.ts" />
|
|
18
|
+
/// <reference path="../next/server/index.d.ts" />
|
|
19
|
+
/// <reference path="../operations/index.d.ts" />
|
|
20
|
+
/// <reference path="../parsers/index.d.ts" />
|
|
21
|
+
/// <reference path="../predicates/index.d.ts" />
|
|
22
|
+
/// <reference path="../promises/index.d.ts" />
|
|
23
|
+
/// <reference path="../strings/index.d.ts" />
|
|
24
|
+
/// <reference path="../tailwind/index.d.ts" />
|
|
25
|
+
/// <reference path="../urls/index.d.ts" />
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* ========================================================================
|
|
3
|
+
* @rzl-zone/utils-js
|
|
4
|
+
* ------------------------------------------------------------------------
|
|
5
|
+
* Version: `3.12.1-beta.1`
|
|
6
|
+
* Author: `Rizalvin Dwiky <rizalvindwiky@gmail.com>`
|
|
7
|
+
* Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/utils-js`
|
|
8
|
+
* ========================================================================
|
|
9
|
+
*/
|
|
10
|
+
"use strict";
|
|
11
|
+
const require_assertIsBoolean = require('./assertIsBoolean-C8WEXVr2.cjs');
|
|
12
|
+
function assertIsArray(value, options) {
|
|
13
|
+
if (require_assertIsBoolean.isArray(value)) return;
|
|
14
|
+
require_assertIsBoolean.resolveErrorMessageAssertions({
|
|
15
|
+
value,
|
|
16
|
+
options,
|
|
17
|
+
requiredValidType: "array"
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
Object.defineProperty(exports, 'assertIsArray', {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
get: function () {
|
|
23
|
+
return assertIsArray;
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
//# sourceMappingURL=assertIsArray-DJXkjHZs.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assertIsArray-DJXkjHZs.cjs","names":["isArray"],"sources":["../src/assertions/objects/assertIsArray.ts"],"sourcesContent":["import type {\n IsArray,\n IsReadonlyArray,\n IsUnknown\n} from \"@rzl-zone/ts-types-plus\";\nimport type { ArrayFallback } from \"@/_private/types.arrays\";\n\nimport { isArray } from \"@/predicates/is/isArray\";\n\nimport {\n resolveErrorMessageAssertions,\n type OptionsAssertIs\n} from \"../_private/assertIs\";\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\ntype AssertIsArrayResult<T> =\n IsUnknown<T> extends true\n ? unknown[] & T\n : IsReadonlyArray<T> extends true\n ? T\n : T extends []\n ? T\n : IsArray<T> extends true\n ? T\n : Extract<T, unknown[] | [] | readonly []>;\n\n/** -------------------------------------------------------\n * * ***Type guard assertion: `assertIsArray`.***\n * -------------------------------------------------------\n * **This function is an **assertion function**.**\n * - **Behavior:**\n * - Validates that the given `value` is an **array**.\n * - After it returns successfully, TypeScript narrows the type of `value` to `array` **(generic support)**.\n * - ✅ If `value` is an `array` ➔ execution continues normally.\n * - ❌ If `value` is not an `array` ➔ throws a built-in error with either:\n * - A custom error message (`options.message`), or\n * - A default message including the actual type.\n * - **⚠️ Error type selection (`options.errorType`):**\n * - You can override the type of error thrown when validation fails.\n * - Must be one of the standard JavaScript built-in errors:\n * - [`TypeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError) |\n * [`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) |\n * [`EvalError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/EvalError) |\n * [`RangeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RangeError) |\n * [`ReferenceError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ReferenceError) |\n * [`SyntaxError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SyntaxError) |\n * [`URIError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/URIError)\n * - **Default:** `\"TypeError\"` if not provided or invalid.\n * @template T - The input type being asserted.\n * @param {*} value - ***The value to validate.***\n * @param {OptionsAssertIs} [options]\n * ***Optional configuration:***\n * - `message`: A custom error message (`string` or `function`).\n * - `errorType`: Built-in JavaScript error type to throw on failure (default `\"TypeError\"`).\n * - `formatCase`: Controls how detected type names are formatted case in error messages.\n * - `useAcronyms`: Control uppercase preservation of recognized acronyms during formatting.\n * @returns {boolean} Narrows `value` to an `array` **(generic support)** if no error is thrown.\n * @throws [`TypeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError) | [`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) | [`EvalError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/EvalError) | [`RangeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RangeError) | [`ReferenceError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ReferenceError) | [`SyntaxError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SyntaxError) | [`URIError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/URIError) if the value is not an array.\n * @example\n * ```ts\n * // ✅ Simple usage\n * assertIsArray([]);\n * assertIsArray([\"123\", 456]);\n * assertIsArray(Array.from([\"abc\"]));\n * // No error, value is array\n *\n * // ❌ Throws TypeError (default behavior)\n * // Case 1: Invalid input type — received a string instead of a array\n * assertIsArray(\"42\");\n * // ➔ TypeError: \"Parameter input (`value`) must be of type `array`, but received: `string`.\"\n *\n * // ❌ Throws custom error type (e.g., RangeError)\n * assertIsArray(async function () {}, { errorType: \"RangeError\" });\n * // ➔ RangeError: \"Parameter input (`value`) must be of type `array`, but received: `async-function`.\"\n *\n * // ❌ Throws a TypeError with a custom string static message\n * assertIsArray(\"123\", { message: \"Must be a array!\" });\n * // ➔ TypeError: \"Must be a array!\"\n *\n * // ❌ Throws a TypeError with a custom message function and formatCase\n * assertIsArray(/regex/, {\n * message: ({ currentType, validType }) => {\n * return `Expected ${validType} but got (${currentType}).`\n * },\n * formatCase: \"toPascalCaseSpace\"\n * });\n * // ➔ TypeError: \"Expected array but got (Reg Exp).\"\n *\n * // ❌ Throws a TypeError with a custom useAcronyms option\n * // Case 1:\n * assertIsArray(new URL(\"https://example.com\"),{\n * message: ({ currentType, validType }) => {\n * return `Expected ${validType} but got (${currentType}).`\n * },\n * });\n * // ➔ TypeError: \"Expected array but got (url).\"\n * assertIsArray(new URL(\"https://example.com\"), {\n * useAcronyms: true,\n * message: ({ currentType, validType }) => {\n * return `Expected ${validType} but got (${currentType}).`\n * },\n * });\n * // ➔ TypeError: \"Expected array but got (URL).\"\n *\n * // Case 2:\n * assertIsArray(new URLSearchParams, {\n * formatCase: \"toPascalCase\",\n * message: ({ currentType, validType }) => {\n * return `Expected ${validType} but got (${currentType}).`\n * },\n * });\n * // ➔ TypeError: \"Expected array but got (UrlSearchParams).\"\n * assertIsArray(new URLSearchParams, {\n * useAcronyms: true,\n * formatCase: \"toPascalCase\",\n * message: ({ currentType, validType }) => {\n * return `Expected ${validType} but got (${currentType}).`\n * },\n * });\n * // ➔ TypeError: \"Expected array but got (URLSearchParams).\"\n * ```\n * -------------------------------------------------------\n * ✅ ***Real-world usage example***:\n * ```ts\n * const mixedValue: string | number[] | undefined = getUserInput();\n *\n * // Runtime assertion: throws if `mixedValue` is not a `number[]`\n * assertIsArray(mixedValue, {\n * errorType: \"RangeError\",\n * message: \"Must be array!\"\n * });\n *\n * // ✅ If no error thrown, TypeScript narrows `mixedValue` to `number[]` here\n * const result: number[] = mixedValue; // ➔ Safe type assignment\n * console.log(result.push(1, 2, 3)); // ➔ Safe to use array methods\n * ```\n */\nexport function assertIsArray(\n value: [],\n options?: OptionsAssertIs\n): asserts value is [];\nexport function assertIsArray<T>(\n value: T,\n options?: OptionsAssertIs\n): asserts value is ArrayFallback<T>;\nexport function assertIsArray(\n value: unknown,\n options?: OptionsAssertIs\n): asserts value is unknown[];\nexport function assertIsArray<T>(value: T, options?: OptionsAssertIs) {\n if (isArray(value)) return;\n\n resolveErrorMessageAssertions({ value, options, requiredValidType: \"array\" });\n}\n"],"mappings":";;;;;;;;;;;;;AAqJA,SAAgB,cAAiB,OAAU,SAA2B;CACpE,IAAIA,gCAAQ,MAAM,EAAE;CAEpB,sDAA8B;EAAE;EAAO;EAAS,mBAAmB;EAAS,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* ========================================================================
|
|
3
|
+
* @rzl-zone/utils-js
|
|
4
|
+
* ------------------------------------------------------------------------
|
|
5
|
+
* Version: `3.12.1-beta.1`
|
|
6
|
+
* Author: `Rizalvin Dwiky <rizalvindwiky@gmail.com>`
|
|
7
|
+
* Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/utils-js`
|
|
8
|
+
* ========================================================================
|
|
9
|
+
*/
|
|
10
|
+
import { M as isArray, n as resolveErrorMessageAssertions } from "./assertIsBoolean-DR1SaXPD.js";
|
|
11
|
+
function assertIsArray(value, options) {
|
|
12
|
+
if (isArray(value)) return;
|
|
13
|
+
resolveErrorMessageAssertions({
|
|
14
|
+
value,
|
|
15
|
+
options,
|
|
16
|
+
requiredValidType: "array"
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
export { assertIsArray as t };
|
|
20
|
+
//# sourceMappingURL=assertIsArray-bTA3XLjq.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assertIsArray-bTA3XLjq.js","names":[],"sources":["../src/assertions/objects/assertIsArray.ts"],"sourcesContent":["import type {\n IsArray,\n IsReadonlyArray,\n IsUnknown\n} from \"@rzl-zone/ts-types-plus\";\nimport type { ArrayFallback } from \"@/_private/types.arrays\";\n\nimport { isArray } from \"@/predicates/is/isArray\";\n\nimport {\n resolveErrorMessageAssertions,\n type OptionsAssertIs\n} from \"../_private/assertIs\";\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\ntype AssertIsArrayResult<T> =\n IsUnknown<T> extends true\n ? unknown[] & T\n : IsReadonlyArray<T> extends true\n ? T\n : T extends []\n ? T\n : IsArray<T> extends true\n ? T\n : Extract<T, unknown[] | [] | readonly []>;\n\n/** -------------------------------------------------------\n * * ***Type guard assertion: `assertIsArray`.***\n * -------------------------------------------------------\n * **This function is an **assertion function**.**\n * - **Behavior:**\n * - Validates that the given `value` is an **array**.\n * - After it returns successfully, TypeScript narrows the type of `value` to `array` **(generic support)**.\n * - ✅ If `value` is an `array` ➔ execution continues normally.\n * - ❌ If `value` is not an `array` ➔ throws a built-in error with either:\n * - A custom error message (`options.message`), or\n * - A default message including the actual type.\n * - **⚠️ Error type selection (`options.errorType`):**\n * - You can override the type of error thrown when validation fails.\n * - Must be one of the standard JavaScript built-in errors:\n * - [`TypeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError) |\n * [`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) |\n * [`EvalError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/EvalError) |\n * [`RangeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RangeError) |\n * [`ReferenceError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ReferenceError) |\n * [`SyntaxError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SyntaxError) |\n * [`URIError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/URIError)\n * - **Default:** `\"TypeError\"` if not provided or invalid.\n * @template T - The input type being asserted.\n * @param {*} value - ***The value to validate.***\n * @param {OptionsAssertIs} [options]\n * ***Optional configuration:***\n * - `message`: A custom error message (`string` or `function`).\n * - `errorType`: Built-in JavaScript error type to throw on failure (default `\"TypeError\"`).\n * - `formatCase`: Controls how detected type names are formatted case in error messages.\n * - `useAcronyms`: Control uppercase preservation of recognized acronyms during formatting.\n * @returns {boolean} Narrows `value` to an `array` **(generic support)** if no error is thrown.\n * @throws [`TypeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError) | [`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) | [`EvalError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/EvalError) | [`RangeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RangeError) | [`ReferenceError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ReferenceError) | [`SyntaxError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SyntaxError) | [`URIError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/URIError) if the value is not an array.\n * @example\n * ```ts\n * // ✅ Simple usage\n * assertIsArray([]);\n * assertIsArray([\"123\", 456]);\n * assertIsArray(Array.from([\"abc\"]));\n * // No error, value is array\n *\n * // ❌ Throws TypeError (default behavior)\n * // Case 1: Invalid input type — received a string instead of a array\n * assertIsArray(\"42\");\n * // ➔ TypeError: \"Parameter input (`value`) must be of type `array`, but received: `string`.\"\n *\n * // ❌ Throws custom error type (e.g., RangeError)\n * assertIsArray(async function () {}, { errorType: \"RangeError\" });\n * // ➔ RangeError: \"Parameter input (`value`) must be of type `array`, but received: `async-function`.\"\n *\n * // ❌ Throws a TypeError with a custom string static message\n * assertIsArray(\"123\", { message: \"Must be a array!\" });\n * // ➔ TypeError: \"Must be a array!\"\n *\n * // ❌ Throws a TypeError with a custom message function and formatCase\n * assertIsArray(/regex/, {\n * message: ({ currentType, validType }) => {\n * return `Expected ${validType} but got (${currentType}).`\n * },\n * formatCase: \"toPascalCaseSpace\"\n * });\n * // ➔ TypeError: \"Expected array but got (Reg Exp).\"\n *\n * // ❌ Throws a TypeError with a custom useAcronyms option\n * // Case 1:\n * assertIsArray(new URL(\"https://example.com\"),{\n * message: ({ currentType, validType }) => {\n * return `Expected ${validType} but got (${currentType}).`\n * },\n * });\n * // ➔ TypeError: \"Expected array but got (url).\"\n * assertIsArray(new URL(\"https://example.com\"), {\n * useAcronyms: true,\n * message: ({ currentType, validType }) => {\n * return `Expected ${validType} but got (${currentType}).`\n * },\n * });\n * // ➔ TypeError: \"Expected array but got (URL).\"\n *\n * // Case 2:\n * assertIsArray(new URLSearchParams, {\n * formatCase: \"toPascalCase\",\n * message: ({ currentType, validType }) => {\n * return `Expected ${validType} but got (${currentType}).`\n * },\n * });\n * // ➔ TypeError: \"Expected array but got (UrlSearchParams).\"\n * assertIsArray(new URLSearchParams, {\n * useAcronyms: true,\n * formatCase: \"toPascalCase\",\n * message: ({ currentType, validType }) => {\n * return `Expected ${validType} but got (${currentType}).`\n * },\n * });\n * // ➔ TypeError: \"Expected array but got (URLSearchParams).\"\n * ```\n * -------------------------------------------------------\n * ✅ ***Real-world usage example***:\n * ```ts\n * const mixedValue: string | number[] | undefined = getUserInput();\n *\n * // Runtime assertion: throws if `mixedValue` is not a `number[]`\n * assertIsArray(mixedValue, {\n * errorType: \"RangeError\",\n * message: \"Must be array!\"\n * });\n *\n * // ✅ If no error thrown, TypeScript narrows `mixedValue` to `number[]` here\n * const result: number[] = mixedValue; // ➔ Safe type assignment\n * console.log(result.push(1, 2, 3)); // ➔ Safe to use array methods\n * ```\n */\nexport function assertIsArray(\n value: [],\n options?: OptionsAssertIs\n): asserts value is [];\nexport function assertIsArray<T>(\n value: T,\n options?: OptionsAssertIs\n): asserts value is ArrayFallback<T>;\nexport function assertIsArray(\n value: unknown,\n options?: OptionsAssertIs\n): asserts value is unknown[];\nexport function assertIsArray<T>(value: T, options?: OptionsAssertIs) {\n if (isArray(value)) return;\n\n resolveErrorMessageAssertions({ value, options, requiredValidType: \"array\" });\n}\n"],"mappings":";;;;;;;;;;;;;AAqJA,SAAgB,cAAiB,OAAU,SAA2B;CACpE,IAAI,QAAQ,MAAM,EAAE;CAEpB,8BAA8B;EAAE;EAAO;EAAS,mBAAmB;EAAS,CAAC"}
|