@rzl-zone/utils-js 3.11.1 → 3.12.1-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.
Files changed (286) hide show
  1. package/{LICENSE.md → LICENSE} +3 -3
  2. package/README.md +62 -89
  3. package/dist/.references/index.d.cts +25 -0
  4. package/dist/.references/index.d.ts +25 -0
  5. package/dist/assertIsArray-BChqwPiP.cjs +26 -0
  6. package/dist/assertIsArray-BChqwPiP.cjs.map +1 -0
  7. package/dist/assertIsArray-BfAbIUfa.js +20 -0
  8. package/dist/assertIsArray-BfAbIUfa.js.map +1 -0
  9. package/dist/assertIsBoolean-BlBct0Fc.js +1073 -0
  10. package/dist/assertIsBoolean-BlBct0Fc.js.map +1 -0
  11. package/dist/assertIsBoolean-DozdtbNi.cjs +1283 -0
  12. package/dist/assertIsBoolean-DozdtbNi.cjs.map +1 -0
  13. package/dist/assertIsString-Bvk7bUL7.cjs +26 -0
  14. package/dist/assertIsString-Bvk7bUL7.cjs.map +1 -0
  15. package/dist/assertIsString-DqV9NwbI.js +20 -0
  16. package/dist/assertIsString-DqV9NwbI.js.map +1 -0
  17. package/dist/assertions/index.cjs +37 -40
  18. package/dist/assertions/index.cjs.map +1 -0
  19. package/dist/assertions/index.d.cts +12 -0
  20. package/dist/assertions/index.d.ts +10 -824
  21. package/dist/assertions/index.js +30 -13
  22. package/dist/assertions/index.js.map +1 -0
  23. package/dist/conversions/index.cjs +34 -103
  24. package/dist/conversions/index.d.cts +12 -0
  25. package/dist/conversions/index.d.ts +10 -1791
  26. package/dist/conversions/index.js +14 -24
  27. package/dist/conversions-CBs8-REq.cjs +448 -0
  28. package/dist/conversions-CBs8-REq.cjs.map +1 -0
  29. package/dist/conversions-EMJa3g-D.js +382 -0
  30. package/dist/conversions-EMJa3g-D.js.map +1 -0
  31. package/dist/events/index.cjs +55 -31
  32. package/dist/events/index.cjs.map +1 -0
  33. package/dist/events/index.d.cts +174 -0
  34. package/dist/events/index.d.ts +31 -35
  35. package/dist/events/index.js +50 -12
  36. package/dist/events/index.js.map +1 -0
  37. package/dist/formatEnvPort-DpIXzPAZ.js +159 -0
  38. package/dist/formatEnvPort-DpIXzPAZ.js.map +1 -0
  39. package/dist/formatEnvPort-hHNvOim-.cjs +171 -0
  40. package/dist/formatEnvPort-hHNvOim-.cjs.map +1 -0
  41. package/dist/formatters/index.cjs +21 -61
  42. package/dist/formatters/index.d.cts +12 -0
  43. package/dist/formatters/index.d.ts +10 -2152
  44. package/dist/formatters/index.js +10 -18
  45. package/dist/formatters-QcZO_Cpx.js +367 -0
  46. package/dist/formatters-QcZO_Cpx.js.map +1 -0
  47. package/dist/formatters-lAYgA11L.cjs +427 -0
  48. package/dist/formatters-lAYgA11L.cjs.map +1 -0
  49. package/dist/generators/index.cjs +161 -41
  50. package/dist/generators/index.cjs.map +1 -0
  51. package/dist/generators/index.d.cts +12 -0
  52. package/dist/generators/index.d.ts +10 -338
  53. package/dist/generators/index.js +154 -14
  54. package/dist/generators/index.js.map +1 -0
  55. package/dist/index-26W7ItWx.d.ts +760 -0
  56. package/dist/index-BPPQjAfs.d.cts +2359 -0
  57. package/dist/index-BXjlgBLz.d.cts +2139 -0
  58. package/dist/index-B_Wwo91H.d.ts +2359 -0
  59. package/dist/index-CpufydcI.d.cts +704 -0
  60. package/dist/index-Czc4O526.d.ts +333 -0
  61. package/dist/index-DPs1_p5G.d.cts +760 -0
  62. package/dist/index-DRpOyBSC.d.ts +1703 -0
  63. package/dist/index-DWWvtHUn.d.cts +822 -0
  64. package/dist/index-DnM0LD0n.d.cts +333 -0
  65. package/dist/index-GUZ9fK6T.d.ts +2139 -0
  66. package/dist/index-I4fAzwXV.d.ts +704 -0
  67. package/dist/index-JDrOl_19.d.ts +822 -0
  68. package/dist/index-b66P49Qe.d.cts +1703 -0
  69. package/dist/isBigInt-B1cijjqm.cjs +20 -0
  70. package/dist/isBigInt-B1cijjqm.cjs.map +1 -0
  71. package/dist/isBigInt-C0bN0Rhu.js +14 -0
  72. package/dist/isBigInt-C0bN0Rhu.js.map +1 -0
  73. package/dist/isEmptyObject-DI42NEo0.cjs +37 -0
  74. package/dist/isEmptyObject-DI42NEo0.cjs.map +1 -0
  75. package/dist/isEmptyObject-DeLVIJpl.js +25 -0
  76. package/dist/isEmptyObject-DeLVIJpl.js.map +1 -0
  77. package/dist/isEmptyString-BTUWYTbw.js +15 -0
  78. package/dist/isEmptyString-BTUWYTbw.js.map +1 -0
  79. package/dist/isEmptyString-CCK3bP74.cjs +21 -0
  80. package/dist/isEmptyString-CCK3bP74.cjs.map +1 -0
  81. package/dist/isEmptyValue-DMSMFTU8.cjs +30 -0
  82. package/dist/isEmptyValue-DMSMFTU8.cjs.map +1 -0
  83. package/dist/isEmptyValue-fjnfQnt5.js +24 -0
  84. package/dist/isEmptyValue-fjnfQnt5.js.map +1 -0
  85. package/dist/isEqual-B1fRgEuU.cjs +111 -0
  86. package/dist/isEqual-B1fRgEuU.cjs.map +1 -0
  87. package/dist/isEqual-DhyP8fB_.js +87 -0
  88. package/dist/isEqual-DhyP8fB_.js.map +1 -0
  89. package/dist/isFinite-BYMOo0os.js +15 -0
  90. package/dist/isFinite-BYMOo0os.js.map +1 -0
  91. package/dist/isFinite-sFkps2TY.cjs +21 -0
  92. package/dist/isFinite-sFkps2TY.cjs.map +1 -0
  93. package/dist/isInteger-DS9V7l_f.js +14 -0
  94. package/dist/isInteger-DS9V7l_f.js.map +1 -0
  95. package/dist/isInteger-FTCthMre.cjs +20 -0
  96. package/dist/isInteger-FTCthMre.cjs.map +1 -0
  97. package/dist/isPlainObject-DcFGh3_5.d.ts +530 -0
  98. package/dist/isPlainObject-doTI11Ib.d.cts +530 -0
  99. package/dist/isServer-D1TXfOs3.js +14 -0
  100. package/dist/isServer-D1TXfOs3.js.map +1 -0
  101. package/dist/isServer-q-QLFCqE.cjs +20 -0
  102. package/dist/isServer-q-QLFCqE.cjs.map +1 -0
  103. package/dist/isTypedArray-47R0wdrc.js +31 -0
  104. package/dist/isTypedArray-47R0wdrc.js.map +1 -0
  105. package/dist/isTypedArray-DiCoqffZ.cjs +43 -0
  106. package/dist/isTypedArray-DiCoqffZ.cjs.map +1 -0
  107. package/dist/isURL-CQiowFq2.js +14 -0
  108. package/dist/isURL-CQiowFq2.js.map +1 -0
  109. package/dist/isURL-WZypXsax.cjs +20 -0
  110. package/dist/isURL-WZypXsax.cjs.map +1 -0
  111. package/dist/isValidDomain-BSXshgkC.cjs +1788 -0
  112. package/dist/isValidDomain-BSXshgkC.cjs.map +1 -0
  113. package/dist/isValidDomain-DwA2EN79.js +1782 -0
  114. package/dist/isValidDomain-DwA2EN79.js.map +1 -0
  115. package/dist/next/index.cjs +119 -212
  116. package/dist/next/index.cjs.map +1 -0
  117. package/dist/next/index.d.cts +226 -0
  118. package/dist/next/index.d.ts +26 -31
  119. package/dist/next/index.js +117 -210
  120. package/dist/next/index.js.map +1 -0
  121. package/dist/next/server/index.cjs +25 -40
  122. package/dist/next/server/index.cjs.map +1 -0
  123. package/dist/next/server/index.d.cts +39 -0
  124. package/dist/next/server/index.d.ts +9 -10
  125. package/dist/next/server/index.js +23 -38
  126. package/dist/next/server/index.js.map +1 -0
  127. package/dist/noop-B2mTBhW-.cjs +18 -0
  128. package/dist/noop-B2mTBhW-.cjs.map +1 -0
  129. package/dist/noop-BzktGBVz.js +12 -0
  130. package/dist/noop-BzktGBVz.js.map +1 -0
  131. package/dist/normalizeSpaces-DQHR3Tlr.cjs +29 -0
  132. package/dist/normalizeSpaces-DQHR3Tlr.cjs.map +1 -0
  133. package/dist/normalizeSpaces-WS_iERJk.js +23 -0
  134. package/dist/normalizeSpaces-WS_iERJk.js.map +1 -0
  135. package/dist/normalizeString-2WLth_Gj.js +15 -0
  136. package/dist/normalizeString-2WLth_Gj.js.map +1 -0
  137. package/dist/normalizeString-D8euBcRD.cjs +21 -0
  138. package/dist/normalizeString-D8euBcRD.cjs.map +1 -0
  139. package/dist/operations/index.cjs +65 -32
  140. package/dist/operations/index.cjs.map +1 -0
  141. package/dist/operations/index.d.cts +139 -0
  142. package/dist/operations/index.d.ts +10 -15
  143. package/dist/operations/index.js +61 -17
  144. package/dist/operations/index.js.map +1 -0
  145. package/dist/parsers/index.cjs +12 -19
  146. package/dist/parsers/index.d.cts +239 -0
  147. package/dist/parsers/index.d.ts +71 -72
  148. package/dist/parsers/index.js +10 -12
  149. package/dist/parsers-DXtpsDyj.cjs +649 -0
  150. package/dist/parsers-DXtpsDyj.cjs.map +1 -0
  151. package/dist/parsers-Dpuq-V4u.js +643 -0
  152. package/dist/parsers-Dpuq-V4u.js.map +1 -0
  153. package/dist/parsing-B43x1sxn.js +50 -0
  154. package/dist/parsing-B43x1sxn.js.map +1 -0
  155. package/dist/parsing-lRoxn1Nz.cjs +56 -0
  156. package/dist/parsing-lRoxn1Nz.cjs.map +1 -0
  157. package/dist/predicates/index.cjs +91 -296
  158. package/dist/predicates/index.d.cts +13 -0
  159. package/dist/predicates/index.d.ts +12 -2482
  160. package/dist/predicates/index.js +23 -25
  161. package/dist/predicates-DiaYA7Ps.cjs +413 -0
  162. package/dist/predicates-DiaYA7Ps.cjs.map +1 -0
  163. package/dist/predicates-gNepszvo.js +257 -0
  164. package/dist/predicates-gNepszvo.js.map +1 -0
  165. package/dist/promises/index.cjs +76 -24
  166. package/dist/promises/index.cjs.map +1 -0
  167. package/dist/promises/index.d.cts +123 -0
  168. package/dist/promises/index.d.ts +28 -31
  169. package/dist/promises/index.js +73 -13
  170. package/dist/promises/index.js.map +1 -0
  171. package/dist/punyCode-CTWXVVFo.cjs +185 -0
  172. package/dist/punyCode-CTWXVVFo.cjs.map +1 -0
  173. package/dist/punyCode-hmiFzLWT.js +179 -0
  174. package/dist/punyCode-hmiFzLWT.js.map +1 -0
  175. package/dist/removeSpaces-BE8lfh-4.js +19 -0
  176. package/dist/removeSpaces-BE8lfh-4.js.map +1 -0
  177. package/dist/removeSpaces-DRRxNWlb.cjs +25 -0
  178. package/dist/removeSpaces-DRRxNWlb.cjs.map +1 -0
  179. package/dist/safeJsonParse-BBnQElk8.cjs +208 -0
  180. package/dist/safeJsonParse-BBnQElk8.cjs.map +1 -0
  181. package/dist/safeJsonParse-CXruaP0p.js +184 -0
  182. package/dist/safeJsonParse-CXruaP0p.js.map +1 -0
  183. package/dist/safeStableStringify-BNh3D0K0.js +88 -0
  184. package/dist/safeStableStringify-BNh3D0K0.js.map +1 -0
  185. package/dist/safeStableStringify-Cc62pfRp.cjs +106 -0
  186. package/dist/safeStableStringify-Cc62pfRp.cjs.map +1 -0
  187. package/dist/strings/index.cjs +76 -81
  188. package/dist/strings/index.cjs.map +1 -0
  189. package/dist/strings/index.d.cts +12 -0
  190. package/dist/strings/index.d.ts +10 -775
  191. package/dist/strings/index.js +59 -14
  192. package/dist/strings/index.js.map +1 -0
  193. package/dist/tailwind/index.cjs +19 -47
  194. package/dist/tailwind/index.d.cts +12 -0
  195. package/dist/tailwind/index.d.ts +11 -712
  196. package/dist/tailwind/index.js +10 -12
  197. package/dist/tailwind-DJ4cmLUw.cjs +247 -0
  198. package/dist/tailwind-DJ4cmLUw.cjs.map +1 -0
  199. package/dist/tailwind-IJvOdkZp.js +199 -0
  200. package/dist/tailwind-IJvOdkZp.js.map +1 -0
  201. package/dist/toStringArrayUnRecursive-CFs0jTEg.js +39 -0
  202. package/dist/toStringArrayUnRecursive-CFs0jTEg.js.map +1 -0
  203. package/dist/toStringArrayUnRecursive-xUaU8Ot9.cjs +51 -0
  204. package/dist/toStringArrayUnRecursive-xUaU8Ot9.cjs.map +1 -0
  205. package/dist/urls/index.cjs +129 -57
  206. package/dist/urls/index.cjs.map +1 -0
  207. package/dist/urls/index.d.cts +740 -0
  208. package/dist/urls/index.d.ts +218 -224
  209. package/dist/urls/index.js +121 -26
  210. package/dist/urls/index.js.map +1 -0
  211. package/package.json +203 -194
  212. package/dist/chunk-22V4WP3H.js +0 -53
  213. package/dist/chunk-2XSZ2ANI.js +0 -63
  214. package/dist/chunk-3T6VSWYX.js +0 -21
  215. package/dist/chunk-5WIEDF2J.js +0 -1823
  216. package/dist/chunk-6EDFZJZ5.cjs +0 -598
  217. package/dist/chunk-6LXWT2I5.js +0 -32
  218. package/dist/chunk-6YGBRENU.js +0 -209
  219. package/dist/chunk-7FGNVDEV.cjs +0 -38
  220. package/dist/chunk-AXDYWO67.js +0 -119
  221. package/dist/chunk-B6PMNZ4M.cjs +0 -35
  222. package/dist/chunk-BAV5T2E3.cjs +0 -15
  223. package/dist/chunk-BLF7SD66.js +0 -95
  224. package/dist/chunk-BMZZXZJ2.cjs +0 -30
  225. package/dist/chunk-BOYP3ARU.js +0 -264
  226. package/dist/chunk-BPYW5YL7.js +0 -16
  227. package/dist/chunk-C2PV3VWC.cjs +0 -118
  228. package/dist/chunk-CCJ2MSN7.js +0 -16
  229. package/dist/chunk-DAPAK2W3.cjs +0 -123
  230. package/dist/chunk-DLS3G6WQ.cjs +0 -23
  231. package/dist/chunk-DNMCR5JH.js +0 -370
  232. package/dist/chunk-DVMHRLKP.cjs +0 -16
  233. package/dist/chunk-EBYFYZW4.cjs +0 -26
  234. package/dist/chunk-ENMRZ4BE.js +0 -302
  235. package/dist/chunk-FJ4BQFVO.js +0 -587
  236. package/dist/chunk-GIKL4PUF.cjs +0 -106
  237. package/dist/chunk-GOFINGT6.js +0 -35
  238. package/dist/chunk-GXKQ3LHF.js +0 -101
  239. package/dist/chunk-HNBRGN4R.js +0 -24
  240. package/dist/chunk-HYN6FC5A.cjs +0 -249
  241. package/dist/chunk-IZGVBYFN.js +0 -242
  242. package/dist/chunk-JIE447J5.js +0 -676
  243. package/dist/chunk-JXEIJM5M.cjs +0 -237
  244. package/dist/chunk-K47GZDBH.js +0 -115
  245. package/dist/chunk-K5536YHG.cjs +0 -269
  246. package/dist/chunk-KHO2SBNA.cjs +0 -16
  247. package/dist/chunk-KXJ7X325.cjs +0 -308
  248. package/dist/chunk-L5RDAVVH.js +0 -14
  249. package/dist/chunk-LJHPTLWB.js +0 -109
  250. package/dist/chunk-M7ELWZXM.cjs +0 -1825
  251. package/dist/chunk-MSUW5VHZ.js +0 -1590
  252. package/dist/chunk-MUHRPRR7.cjs +0 -65
  253. package/dist/chunk-MV3TSQSH.cjs +0 -397
  254. package/dist/chunk-NLZLXWAU.cjs +0 -678
  255. package/dist/chunk-NVRZPF5M.cjs +0 -18
  256. package/dist/chunk-ONZFBJVW.js +0 -14
  257. package/dist/chunk-PGNL7JXO.cjs +0 -251
  258. package/dist/chunk-Q4GEQS7X.cjs +0 -564
  259. package/dist/chunk-QNKGP5DY.js +0 -14
  260. package/dist/chunk-QYI2VJLS.cjs +0 -211
  261. package/dist/chunk-RBWZII5I.js +0 -59
  262. package/dist/chunk-RMP7VMPB.cjs +0 -33
  263. package/dist/chunk-RZOGBYIS.js +0 -21
  264. package/dist/chunk-SU3UELUB.cjs +0 -36
  265. package/dist/chunk-SYHPSOUU.cjs +0 -1626
  266. package/dist/chunk-SZUNAEMR.js +0 -246
  267. package/dist/chunk-TER22LO4.cjs +0 -64
  268. package/dist/chunk-TJHGRQ4P.js +0 -33
  269. package/dist/chunk-U23I7JPB.cjs +0 -56
  270. package/dist/chunk-U7HHN47R.js +0 -552
  271. package/dist/chunk-UDA26MCU.cjs +0 -16
  272. package/dist/chunk-UIAWUZ4H.js +0 -31
  273. package/dist/chunk-ULQPCIA2.js +0 -16
  274. package/dist/chunk-VJDDGRIK.cjs +0 -16
  275. package/dist/chunk-WETQI6HM.js +0 -232
  276. package/dist/chunk-WLOQQFDS.cjs +0 -18
  277. package/dist/chunk-WVSPXFTY.js +0 -14
  278. package/dist/chunk-WXFTVXBF.cjs +0 -23
  279. package/dist/chunk-XPVTIGU2.cjs +0 -113
  280. package/dist/chunk-XX6RUGTM.cjs +0 -18
  281. package/dist/chunk-YWHHVDT4.js +0 -13
  282. package/dist/chunk-ZPDMWDGZ.cjs +0 -101
  283. package/dist/chunk-ZVWZEGQP.js +0 -28
  284. package/dist/index.d.ts +0 -24
  285. package/dist/isPlainObject-0p3VveWr.d.ts +0 -534
  286. package/dist/rzl-utils.global.js +0 -10
@@ -1,232 +0,0 @@
1
- /*!
2
- * ====================================================
3
- * Rzl Utils-JS.
4
- * ----------------------------------------------------
5
- * Version: 3.11.1.
6
- * Author: Rizalvin Dwiky.
7
- * Repository: https://github.com/rzl-zone/utils-js.
8
- * ====================================================
9
- */
10
- import { isURL } from './chunk-ONZFBJVW.js';
11
- import { normalizeString } from './chunk-BPYW5YL7.js';
12
- import { toStringArrayUnRecursive } from './chunk-22V4WP3H.js';
13
- import { isEmptyValue } from './chunk-UIAWUZ4H.js';
14
- import { isInteger } from './chunk-WVSPXFTY.js';
15
- import { normalizePathname } from './chunk-SZUNAEMR.js';
16
- import { isEmptyString } from './chunk-ULQPCIA2.js';
17
- import { assertIsArray } from './chunk-RZOGBYIS.js';
18
- import { safeStableStringify } from './chunk-AXDYWO67.js';
19
- import { isString, getPreciseType, isUndefined, isNonEmptyString, isFunction, isNumber, isError, isArray, isNil, isNull, isPlainObject, isBoolean, isNonEmptyArray } from './chunk-MSUW5VHZ.js';
20
-
21
- var constructURL = (baseUrl, queryParams, removeParams) => {
22
- if (isString(baseUrl)) {
23
- if (isEmptyString(baseUrl)) {
24
- throw new TypeError(`First parameter (\`baseUrl\`) cannot be an empty-string.`);
25
- }
26
- baseUrl = normalizeString(baseUrl);
27
- } else if (!isURL(baseUrl)) {
28
- throw new TypeError(
29
- `First parameter (\`baseUrl\`) must be of type an URL instance or a \`string\` and a non empty-string, but received: \`${getPreciseType(
30
- baseUrl
31
- )}\`, with current value: \`${safeStableStringify(baseUrl, {
32
- keepUndefined: true
33
- })}\`.`
34
- );
35
- }
36
- if (!isUndefined(removeParams)) {
37
- assertIsArray(removeParams, {
38
- message: ({ currentType, validType }) => `Third parameter (\`removeParams\`) must be of type \`${validType} of strings\`, but received: \`${currentType}\`.`
39
- });
40
- if (!removeParams.every((param) => isNonEmptyString(param))) {
41
- throw new TypeError(
42
- `Third parameter (\`removeParams\`) must be of type \`array\` and contains \`string\` only and non empty-string.`
43
- );
44
- }
45
- }
46
- try {
47
- if (!isUndefined(queryParams) && !isFunction(queryParams[Symbol.iterator])) {
48
- throw new TypeError(
49
- `Second parameter (\`queryParams\`) must be iterable (like URLSearchParams.entries() or an array of [[string, string | number]...]), but received: \`${getPreciseType(
50
- queryParams
51
- )}\`, with value: \`${safeStableStringify(queryParams, {
52
- keepUndefined: true
53
- })}\`.`
54
- );
55
- }
56
- const urlInstance = new URL(baseUrl);
57
- if (!isUndefined(queryParams)) {
58
- const paramObject = Object.fromEntries(queryParams);
59
- if (!isEmptyValue(paramObject)) {
60
- const mergedParams = new URLSearchParams(urlInstance.search);
61
- for (const [key, value] of Object.entries(paramObject)) {
62
- if (!isNonEmptyString(value) && !isNumber(value, { includeNaN: true })) {
63
- throw new TypeError(
64
- `Second parameter (\`queryParams\`) must be iterable (like URLSearchParams.entries() or an array of [[string, string | number]...]), but received: \`${getPreciseType(
65
- queryParams
66
- )}\`, with value: \`${safeStableStringify(queryParams, {
67
- keepUndefined: true
68
- })}\`.`
69
- );
70
- }
71
- mergedParams.set(key, String(value));
72
- }
73
- if (removeParams?.length) {
74
- toStringArrayUnRecursive(removeParams).map((paramKey) => {
75
- mergedParams.delete(paramKey);
76
- });
77
- }
78
- urlInstance.search = mergedParams.toString();
79
- }
80
- }
81
- removeParams?.forEach((param) => urlInstance.searchParams.delete(param));
82
- return urlInstance;
83
- } catch (error) {
84
- if (isError(error)) throw error;
85
- throw new Error(
86
- "Failed to construct a valid URL in `constructURL()`, Error:" + error
87
- );
88
- }
89
- };
90
-
91
- var extractURLs = (url) => {
92
- if (!isNonEmptyString(url)) return null;
93
- let decoded;
94
- try {
95
- decoded = decodeURIComponent(url);
96
- } catch {
97
- return null;
98
- }
99
- const urlPattern = /https?:\/\/.*?(?=https?:\/\/|\s|$)/g;
100
- const matches = decoded.match(urlPattern);
101
- if (!matches) return null;
102
- const cleaned = matches.map((url2) => url2.replace(/[.,;:!?)]*$/, "")).filter((url2) => {
103
- try {
104
- const u = new URL(url2);
105
- return u.protocol === "http:" || u.protocol === "https:";
106
- } catch {
107
- return false;
108
- }
109
- });
110
- return cleaned.length ? cleaned : null;
111
- };
112
-
113
- var getFirstPrefixPathname = (result, defaultValue = "/") => {
114
- if (!isNonEmptyString(defaultValue)) {
115
- throw new TypeError(
116
- `Second parameter (\`defaultValue\`) must be of type \`string\` and not an \`empty-string\`, but received: \`${getPreciseType(
117
- defaultValue
118
- )}\`, with value: \`${safeStableStringify(defaultValue, {
119
- keepUndefined: true
120
- })}\`.`
121
- );
122
- }
123
- if (isArray(result)) {
124
- if (!result.every((item) => isString(item))) {
125
- throw new TypeError(
126
- `First parameter (\`result\`) must be of type \`string\` or \`array of string\`, but received: \`${getPreciseType(
127
- result
128
- )}\`, with value: \`${safeStableStringify(result, {
129
- keepUndefined: true
130
- })}\`.`
131
- );
132
- }
133
- for (const item of result) {
134
- const normalized = normalizePathname(item);
135
- if (normalized !== "/") {
136
- return normalized;
137
- }
138
- }
139
- return normalizePathname(defaultValue);
140
- }
141
- if (isString(result)) {
142
- const normalized = normalizePathname(result);
143
- return normalized !== "/" ? normalized : normalizePathname(defaultValue);
144
- }
145
- if (!isNil(result)) {
146
- throw new TypeError(
147
- `First parameter (\`result\`) must be of type \`string\`, \`array-string\`, \`null\` or \`undefined\`, but received: \`${getPreciseType(
148
- result
149
- )}\`.`
150
- );
151
- }
152
- return normalizePathname(defaultValue);
153
- };
154
-
155
- var getPrefixPathname = (url, base = null, options = {}) => {
156
- const errors = [];
157
- if (!isString(url) && !isArray(url)) {
158
- errors.push(
159
- `First parameter (\`url\`) must be of type \`string\` or \`array-string\`, but received: \`${getPreciseType(
160
- url
161
- )}\`.`
162
- );
163
- }
164
- if (!isString(base) && !isArray(base) && !isNull(base)) {
165
- errors.push(
166
- `Second parameter (\`base\`) must be of type \`string\`, \`array-string\` or \`null\`, but received: \`${getPreciseType(
167
- base
168
- )}\`.`
169
- );
170
- }
171
- if (!isPlainObject(options)) {
172
- errors.push(
173
- `Second parameter (\`options\`) must be of type \`plain-object\`, but received: \`${getPreciseType(
174
- options
175
- )}\`.`
176
- );
177
- }
178
- const { levels = 1, removeDuplicates = true } = options;
179
- if (!isInteger(levels) || isInteger(levels) && levels < 0) {
180
- errors.push(
181
- `Parameter \`levels\` property of the \`options\` (second parameter) must be of type \`integer-number\` and minimum is \`0\`, but received: \`${getPreciseType(
182
- levels
183
- )}\`, with value: \`${safeStableStringify(levels, {
184
- keepUndefined: true
185
- })}\`.`
186
- );
187
- }
188
- if (!isBoolean(removeDuplicates)) {
189
- errors.push(
190
- `Parameter \`removeDuplicates\` property of the \`options\` (second parameter) must be of type \`boolean\`, but received: \`${getPreciseType(
191
- removeDuplicates
192
- )}\`.`
193
- );
194
- }
195
- if (isNonEmptyArray(errors)) {
196
- throw new TypeError(
197
- `Invalid parameter(s) in \`getPrefixPathname\` function:
198
- - ${errors.join("\n- ")}`
199
- );
200
- }
201
- function getLevel(singleUrl) {
202
- const parts = normalizePathname(singleUrl).split("/").filter(Boolean);
203
- return `/${parts.slice(0, levels).join("/")}`;
204
- }
205
- function processUrl(singleUrl) {
206
- if (base) {
207
- singleUrl = normalizePathname(singleUrl);
208
- if (isArray(base)) {
209
- for (const b of base) {
210
- if (singleUrl.startsWith(normalizePathname(b))) {
211
- return getLevel(singleUrl);
212
- }
213
- }
214
- } else if (isNonEmptyString(base) && singleUrl.startsWith(normalizePathname(base))) {
215
- return getLevel(singleUrl);
216
- }
217
- return null;
218
- }
219
- return getLevel(singleUrl);
220
- }
221
- if (isArray(url)) {
222
- const result = url.map(processUrl).filter((r) => !isNull(r));
223
- const uniqueResult = removeDuplicates ? [...new Set(result)] : result;
224
- if (uniqueResult.length === 1) {
225
- return uniqueResult[0];
226
- }
227
- return uniqueResult;
228
- }
229
- return processUrl(url);
230
- };
231
-
232
- export { constructURL, extractURLs, getFirstPrefixPathname, getPrefixPathname };
@@ -1,18 +0,0 @@
1
- /*!
2
- * ====================================================
3
- * Rzl Utils-JS.
4
- * ----------------------------------------------------
5
- * Version: 3.11.1.
6
- * Author: Rizalvin Dwiky.
7
- * Repository: https://github.com/rzl-zone/utils-js.
8
- * ====================================================
9
- */
10
- 'use strict';
11
-
12
- var chunkSYHPSOUU_cjs = require('./chunk-SYHPSOUU.cjs');
13
-
14
- var isEmptyString = (value, options = {}) => {
15
- return !chunkSYHPSOUU_cjs.isNonEmptyString(value, options);
16
- };
17
-
18
- exports.isEmptyString = isEmptyString;
@@ -1,14 +0,0 @@
1
- /*!
2
- * ====================================================
3
- * Rzl Utils-JS.
4
- * ----------------------------------------------------
5
- * Version: 3.11.1.
6
- * Author: Rizalvin Dwiky.
7
- * Repository: https://github.com/rzl-zone/utils-js.
8
- * ====================================================
9
- */
10
- function isInteger(value) {
11
- return typeof value === "number" && Number.isInteger(value);
12
- }
13
-
14
- export { isInteger };
@@ -1,23 +0,0 @@
1
- /*!
2
- * ====================================================
3
- * Rzl Utils-JS.
4
- * ----------------------------------------------------
5
- * Version: 3.11.1.
6
- * Author: Rizalvin Dwiky.
7
- * Repository: https://github.com/rzl-zone/utils-js.
8
- * ====================================================
9
- */
10
- 'use strict';
11
-
12
- var chunkSYHPSOUU_cjs = require('./chunk-SYHPSOUU.cjs');
13
-
14
- var assertIsString = (value, options = {}) => {
15
- if (chunkSYHPSOUU_cjs.isString(value)) return;
16
- chunkSYHPSOUU_cjs.resolveErrorMessageAssertions({
17
- value,
18
- options,
19
- requiredValidType: "string"
20
- });
21
- };
22
-
23
- exports.assertIsString = assertIsString;
@@ -1,113 +0,0 @@
1
- /*!
2
- * ====================================================
3
- * Rzl Utils-JS.
4
- * ----------------------------------------------------
5
- * Version: 3.11.1.
6
- * Author: Rizalvin Dwiky.
7
- * Repository: https://github.com/rzl-zone/utils-js.
8
- * ====================================================
9
- */
10
- 'use strict';
11
-
12
- var chunkK5536YHG_cjs = require('./chunk-K5536YHG.cjs');
13
- var chunkGIKL4PUF_cjs = require('./chunk-GIKL4PUF.cjs');
14
- var chunk7FGNVDEV_cjs = require('./chunk-7FGNVDEV.cjs');
15
- var chunkDLS3G6WQ_cjs = require('./chunk-DLS3G6WQ.cjs');
16
- var chunkDAPAK2W3_cjs = require('./chunk-DAPAK2W3.cjs');
17
- var chunkSYHPSOUU_cjs = require('./chunk-SYHPSOUU.cjs');
18
-
19
- var findDuplicates = (values) => {
20
- chunkDLS3G6WQ_cjs.assertIsArray(values, {
21
- message: ({ currentType, validType }) => `First parameter (\`values\`) must be of type \`${validType}\` (array literal or instance), but received: \`${currentType}\`.`
22
- });
23
- const duplicates = [];
24
- values.forEach((item, index) => {
25
- for (let i = index + 1; i < values.length; i++) {
26
- if (chunkGIKL4PUF_cjs.isEqual(item, values[i])) {
27
- if (!duplicates.some((dup) => chunkGIKL4PUF_cjs.isEqual(dup, item))) {
28
- duplicates.push(item);
29
- }
30
- break;
31
- }
32
- }
33
- });
34
- return duplicates;
35
- };
36
-
37
- var omitKeys = (object, keysToOmit) => {
38
- if (!chunkSYHPSOUU_cjs.isPlainObject(object)) return {};
39
- chunkDLS3G6WQ_cjs.assertIsArray(keysToOmit, {
40
- message: ({ currentType, validType }) => `Second parameter (\`keysToOmit\`) must be of type \`${validType}\` (array literal or instance), but received: \`${currentType}\`.`
41
- });
42
- const duplicates = findDuplicates(keysToOmit);
43
- if (duplicates.length > 0) {
44
- throw new Error(
45
- `Function "omitKeys" Error: Duplicate keys detected - \`${duplicates}\``
46
- );
47
- }
48
- return Object.fromEntries(
49
- Object.entries(object).filter(([key]) => !keysToOmit.includes(key))
50
- );
51
- };
52
-
53
- var omitKeysDeep = (object, keysToOmit) => {
54
- if (!chunkSYHPSOUU_cjs.isPlainObject(object)) return {};
55
- chunkDLS3G6WQ_cjs.assertIsArray(keysToOmit, {
56
- message: ({ currentType, validType }) => `Second parameter (\`keysToOmit\`) must be of type \`${validType}\` (array literal or instance), but received: \`${currentType}\`.`
57
- });
58
- const duplicates = findDuplicates(keysToOmit);
59
- if (chunkSYHPSOUU_cjs.isNonEmptyArray(duplicates)) {
60
- throw new Error(
61
- `Function "omitKeysDeep" Error: Duplicate keys detected - \`${chunkDAPAK2W3_cjs.safeStableStringify(
62
- duplicates,
63
- {
64
- keepUndefined: true
65
- }
66
- )}\`.`
67
- );
68
- }
69
- const omitAtPath = (obj, pathParts) => {
70
- if (!chunkSYHPSOUU_cjs.isObjectOrArray(obj)) return obj;
71
- const [current, ...rest] = pathParts;
72
- if (chunk7FGNVDEV_cjs.isEmptyArray(rest)) {
73
- if (chunkSYHPSOUU_cjs.isArray(obj)) {
74
- const index = parseInt(current);
75
- if (!chunkSYHPSOUU_cjs.isNaN(index) && index in obj) {
76
- obj.splice(index, 1);
77
- }
78
- } else {
79
- delete obj[current];
80
- }
81
- } else {
82
- const next = obj[current];
83
- if (chunkSYHPSOUU_cjs.isObjectOrArray(next)) {
84
- obj[current] = omitAtPath(next, rest);
85
- }
86
- }
87
- return obj;
88
- };
89
- const deepRemoveEmptyObjects = (obj) => {
90
- if (chunkSYHPSOUU_cjs.isArray(obj)) {
91
- return obj.map(deepRemoveEmptyObjects).filter((item) => !(chunkSYHPSOUU_cjs.isObjectOrArray(item) && Object.keys(item).length === 0));
92
- }
93
- if (chunkSYHPSOUU_cjs.isObjectOrArray(obj)) {
94
- const cleaned = Object.fromEntries(
95
- Object.entries(obj).map(([k, v]) => [k, deepRemoveEmptyObjects(v)]).filter(
96
- ([, v]) => !chunkSYHPSOUU_cjs.isUndefined(v) && !(chunkSYHPSOUU_cjs.isObjectOrArray(v) && Object.keys(v).length === 0)
97
- )
98
- );
99
- return cleaned;
100
- }
101
- return obj;
102
- };
103
- const result = chunkK5536YHG_cjs.safeJsonParse(chunkDAPAK2W3_cjs.safeStableStringify(object));
104
- for (const key of keysToOmit) {
105
- const parts = key.split(".");
106
- omitAtPath(result, parts);
107
- }
108
- return deepRemoveEmptyObjects(result);
109
- };
110
-
111
- exports.findDuplicates = findDuplicates;
112
- exports.omitKeys = omitKeys;
113
- exports.omitKeysDeep = omitKeysDeep;
@@ -1,18 +0,0 @@
1
- /*!
2
- * ====================================================
3
- * Rzl Utils-JS.
4
- * ----------------------------------------------------
5
- * Version: 3.11.1.
6
- * Author: Rizalvin Dwiky.
7
- * Repository: https://github.com/rzl-zone/utils-js.
8
- * ====================================================
9
- */
10
- 'use strict';
11
-
12
- var chunkSYHPSOUU_cjs = require('./chunk-SYHPSOUU.cjs');
13
-
14
- function isFinite(value) {
15
- return chunkSYHPSOUU_cjs.isNumber(value) && Number.isFinite(value);
16
- }
17
-
18
- exports.isFinite = isFinite;
@@ -1,13 +0,0 @@
1
- /*!
2
- * ====================================================
3
- * Rzl Utils-JS.
4
- * ----------------------------------------------------
5
- * Version: 3.11.1.
6
- * Author: Rizalvin Dwiky.
7
- * Repository: https://github.com/rzl-zone/utils-js.
8
- * ====================================================
9
- */
10
- var noop = () => {
11
- };
12
-
13
- export { noop };
@@ -1,101 +0,0 @@
1
- /*!
2
- * ====================================================
3
- * Rzl Utils-JS.
4
- * ----------------------------------------------------
5
- * Version: 3.11.1.
6
- * Author: Rizalvin Dwiky.
7
- * Repository: https://github.com/rzl-zone/utils-js.
8
- * ====================================================
9
- */
10
- 'use strict';
11
-
12
- var chunkWLOQQFDS_cjs = require('./chunk-WLOQQFDS.cjs');
13
- var chunkSYHPSOUU_cjs = require('./chunk-SYHPSOUU.cjs');
14
-
15
- var capitalizeFirst = (string, options = {
16
- lowerCaseNextRest: true,
17
- trim: false
18
- }) => {
19
- if (!chunkSYHPSOUU_cjs.isNonEmptyString(string)) return "";
20
- if (!chunkSYHPSOUU_cjs.isPlainObject(options)) {
21
- options = {};
22
- }
23
- const lowerCaseNextRest = options.lowerCaseNextRest !== false;
24
- const trim = options.trim === true;
25
- if (trim) string = string.trim();
26
- return string[0].toUpperCase() + (lowerCaseNextRest ? string.slice(1).toLowerCase() : string.slice(1));
27
- };
28
-
29
- var capitalizeWords = (value, options = {
30
- collapseSpaces: false,
31
- trim: false
32
- }) => {
33
- if (!chunkSYHPSOUU_cjs.isNonEmptyString(value)) return "";
34
- let result = value;
35
- if (!chunkSYHPSOUU_cjs.isPlainObject(options)) {
36
- options = {};
37
- }
38
- const collapseSpaces = options.collapseSpaces === true;
39
- const trim = options.trim === true;
40
- if (trim) {
41
- result = result.trim();
42
- }
43
- if (collapseSpaces) {
44
- const leadingSpaces = result.match(/^\s*/)?.[0] ?? "";
45
- const trailingSpaces = result.match(/\s*$/)?.[0] ?? "";
46
- result = result.trim().replace(/\s+/g, " ");
47
- result = `${leadingSpaces}${result}${trailingSpaces}`;
48
- }
49
- return result.toLowerCase().split(" ").map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(" ");
50
- };
51
-
52
- function stripHtmlTags(input) {
53
- if (!chunkSYHPSOUU_cjs.isString(input)) {
54
- return void 0;
55
- }
56
- if (chunkWLOQQFDS_cjs.isEmptyString(input)) {
57
- return "";
58
- }
59
- const stripped = input.replace(/<\/?[a-zA-Z][^<>]*\/?>/g, " ").trim();
60
- const cleaned = stripped.replace(/\s+/g, " ").trim();
61
- return cleaned;
62
- }
63
-
64
- var getInitialsName = (name) => {
65
- if (!chunkSYHPSOUU_cjs.isNonEmptyString(name)) return "";
66
- name = name.replace(/\s+/g, " ").trim();
67
- const nameParts = name.split(" ");
68
- if (nameParts.length > 1) {
69
- return nameParts[0][0] + nameParts[1][0].toUpperCase();
70
- }
71
- return name.length > 1 ? name.substring(0, 2).toUpperCase() : (
72
- // First two letters for single-word names
73
- name[0].toUpperCase()
74
- );
75
- };
76
-
77
- var replaceAt = (index, originalString, replaceTo) => {
78
- if (!chunkSYHPSOUU_cjs.isNumber(index) || !chunkSYHPSOUU_cjs.isString(replaceTo) || !chunkSYHPSOUU_cjs.isString(originalString)) {
79
- throw new TypeError(
80
- `First parameter (\`index\`) must be of type \`number\`, second parameter (\`originalString\`) and third parameter (\`replaceTo\`) must be of type \`string\`, but received: "['index': \`${chunkSYHPSOUU_cjs.getPreciseType(
81
- index
82
- )}\`, 'originalString': \`${chunkSYHPSOUU_cjs.getPreciseType(
83
- originalString
84
- )}\`, 'replaceTo': \`${chunkSYHPSOUU_cjs.getPreciseType(replaceTo)}\`]".`
85
- );
86
- }
87
- if (index < 0 || index >= originalString.length) {
88
- throw new RangeError(
89
- `First parameter (\`index\`) is out of range from second parameter (\`originalString\`).`
90
- );
91
- }
92
- return originalString.slice(0, index) + // Extract before the index
93
- replaceTo + // Insert replacement
94
- originalString.slice(index + 1);
95
- };
96
-
97
- exports.capitalizeFirst = capitalizeFirst;
98
- exports.capitalizeWords = capitalizeWords;
99
- exports.getInitialsName = getInitialsName;
100
- exports.replaceAt = replaceAt;
101
- exports.stripHtmlTags = stripHtmlTags;
@@ -1,28 +0,0 @@
1
- /*!
2
- * ====================================================
3
- * Rzl Utils-JS.
4
- * ----------------------------------------------------
5
- * Version: 3.11.1.
6
- * Author: Rizalvin Dwiky.
7
- * Repository: https://github.com/rzl-zone/utils-js.
8
- * ====================================================
9
- */
10
- import { isNonEmptyString, isPlainObject } from './chunk-MSUW5VHZ.js';
11
-
12
- var normalizeSpaces = (value, options = {
13
- withTrim: true,
14
- trimOnly: false
15
- }) => {
16
- if (!isNonEmptyString(value)) return "";
17
- if (!isPlainObject(options)) {
18
- options = {};
19
- }
20
- const { trimOnly = false, withTrim = true } = options;
21
- if (trimOnly) return value.trim();
22
- if (withTrim) {
23
- value = value.trim();
24
- }
25
- return value.replace(/\s+/g, " ");
26
- };
27
-
28
- export { normalizeSpaces };
package/dist/index.d.ts DELETED
@@ -1,24 +0,0 @@
1
- /*!
2
- * ====================================================
3
- * Rzl Utils-JS.
4
- * ----------------------------------------------------
5
- * Version: 3.11.1.
6
- * Author: Rizalvin Dwiky.
7
- * Repository: https://github.com/rzl-zone/utils-js.
8
- * ====================================================
9
- */
10
- //! References Paths:
11
- /// <reference path="./assertions/index.d.ts" />
12
- /// <reference path="./conversions/index.d.ts" />
13
- /// <reference path="./events/index.d.ts" />
14
- /// <reference path="./formatters/index.d.ts" />
15
- /// <reference path="./generators/index.d.ts" />
16
- /// <reference path="./next/index.d.ts" />
17
- /// <reference path="./next/server/index.d.ts" />
18
- /// <reference path="./operations/index.d.ts" />
19
- /// <reference path="./parsers/index.d.ts" />
20
- /// <reference path="./predicates/index.d.ts" />
21
- /// <reference path="./promises/index.d.ts" />
22
- /// <reference path="./strings/index.d.ts" />
23
- /// <reference path="./tailwind/index.d.ts" />
24
- /// <reference path="./urls/index.d.ts" />