@rzl-zone/utils-js 3.7.1 → 3.9.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 (124) hide show
  1. package/README.md +28 -1
  2. package/dist/assertions/index.cjs +11 -11
  3. package/dist/assertions/index.d.ts +169 -58
  4. package/dist/assertions/index.js +5 -5
  5. package/dist/{chunk-EK7FSI7F.cjs → chunk-2XGQQZ6A.cjs} +3 -3
  6. package/dist/{chunk-YS27V6LS.js → chunk-3LE6NX57.js} +5 -176
  7. package/dist/{chunk-PZQC3FZY.js → chunk-44X74C26.js} +4 -4
  8. package/dist/{chunk-4ACKNPL5.js → chunk-5KDVIEVO.js} +2 -2
  9. package/dist/{chunk-JY4HLZ4W.js → chunk-5O66AUEC.js} +2 -2
  10. package/dist/chunk-5Y6JL47L.js +302 -0
  11. package/dist/{chunk-KIYALQQF.cjs → chunk-62FS7WMB.cjs} +35 -35
  12. package/dist/{chunk-VJVCXEH7.cjs → chunk-6AMDHVS2.cjs} +9 -181
  13. package/dist/{chunk-6PKW4WCT.js → chunk-6WVOUVWD.js} +27 -15
  14. package/dist/{chunk-BYUT376O.cjs → chunk-76ATVDCR.cjs} +3 -3
  15. package/dist/{chunk-F3WBQKRI.cjs → chunk-7C7TQC5J.cjs} +29 -7
  16. package/dist/{chunk-QUITZ3GP.js → chunk-7EIFPHV3.js} +32 -16
  17. package/dist/{chunk-6RFNZ2ZZ.cjs → chunk-7NXFGJJE.cjs} +14 -14
  18. package/dist/{chunk-TFDXRT6D.cjs → chunk-ALRISPTL.cjs} +3 -3
  19. package/dist/chunk-BAV5T2E3.cjs +1 -1
  20. package/dist/{chunk-4ZOXSUXB.js → chunk-C7GC2PFX.js} +3 -3
  21. package/dist/chunk-DVMHRLKP.cjs +1 -1
  22. package/dist/{chunk-XFTUHS4Y.js → chunk-DXPM4NOU.js} +10 -8
  23. package/dist/{chunk-DPLL67OT.js → chunk-EJV5AF4L.js} +2 -2
  24. package/dist/{chunk-NREACG6M.cjs → chunk-FWWPEL7J.cjs} +3 -3
  25. package/dist/{chunk-LEX4TQW2.js → chunk-GHU356XQ.js} +4 -6
  26. package/dist/chunk-GKDSBOYE.js +209 -0
  27. package/dist/{chunk-YC7AK3KX.cjs → chunk-H44QVAZL.cjs} +31 -31
  28. package/dist/{chunk-AKKM6MOX.cjs → chunk-I33PB44Q.cjs} +15 -15
  29. package/dist/{chunk-LIU4S3JA.cjs → chunk-IX6PF5ZP.cjs} +4 -4
  30. package/dist/{chunk-3KTD3QDI.js → chunk-J4TT33ZX.js} +29 -7
  31. package/dist/{chunk-SZJ7OI4S.js → chunk-J6VLFVIL.js} +3 -3
  32. package/dist/{chunk-KTQLDIIT.cjs → chunk-JI57K7D4.cjs} +173 -163
  33. package/dist/{chunk-OFBFGFVH.js → chunk-JYOCB6OV.js} +2 -2
  34. package/dist/chunk-KHO2SBNA.cjs +1 -1
  35. package/dist/{chunk-66WLOZOD.cjs → chunk-KUVRZ2JW.cjs} +53 -51
  36. package/dist/chunk-L5RDAVVH.js +1 -1
  37. package/dist/{chunk-VCVND6CH.js → chunk-M5QB2GM5.js} +2 -2
  38. package/dist/{chunk-3LEWQV3R.js → chunk-MBFVTGYS.js} +8 -8
  39. package/dist/{chunk-UKAUXY2U.cjs → chunk-MMRHKYT6.cjs} +12 -12
  40. package/dist/{chunk-U5VR4TJN.js → chunk-MS2KSKD7.js} +9 -9
  41. package/dist/{chunk-7ZNEUWYP.js → chunk-MZ3T6L7Z.js} +2 -2
  42. package/dist/{chunk-ATLFMKAF.cjs → chunk-NAOVH4OH.cjs} +7 -7
  43. package/dist/chunk-NJ24M6ZH.cjs +308 -0
  44. package/dist/chunk-OCTHWEZK.cjs +249 -0
  45. package/dist/chunk-ONZFBJVW.js +1 -1
  46. package/dist/{chunk-FI76UZRF.js → chunk-OSSFLQDD.js} +3 -4
  47. package/dist/{chunk-7WBMA2VE.cjs → chunk-OYFUBKEG.cjs} +4 -5
  48. package/dist/{chunk-B4SDEBN7.cjs → chunk-PWKOFPAH.cjs} +3 -3
  49. package/dist/{chunk-2CQI36UD.cjs → chunk-QGTFQ7RO.cjs} +8 -6
  50. package/dist/chunk-QNKGP5DY.js +1 -1
  51. package/dist/chunk-QXTJVDWE.js +676 -0
  52. package/dist/{chunk-B6UIKBHR.cjs → chunk-QZI5PVCI.cjs} +4 -4
  53. package/dist/{chunk-WNO3EPYT.js → chunk-R2DR7SPJ.js} +102 -26
  54. package/dist/{chunk-TDYGYHSH.js → chunk-SN5HAK3Y.js} +4 -4
  55. package/dist/{chunk-D53CE4BT.js → chunk-SRWL4YCP.js} +11 -8
  56. package/dist/{chunk-7QQV66RX.cjs → chunk-TJ5OY6MC.cjs} +10 -10
  57. package/dist/{chunk-6WMB5AJR.js → chunk-TXOVQZPU.js} +3 -4
  58. package/dist/chunk-UDA26MCU.cjs +1 -1
  59. package/dist/{chunk-R3PBF6F7.cjs → chunk-UFYMRRJH.cjs} +73 -61
  60. package/dist/{chunk-5NN4ZDE2.cjs → chunk-UV5BKAYW.cjs} +6 -8
  61. package/dist/{chunk-GAJBF6DR.js → chunk-UXT4XSUK.js} +2 -2
  62. package/dist/{chunk-TDPYR5JY.js → chunk-VBSLIIDB.js} +24 -14
  63. package/dist/chunk-VCYXNIZ2.cjs +678 -0
  64. package/dist/chunk-VJDDGRIK.cjs +1 -1
  65. package/dist/{chunk-VNADVWSJ.js → chunk-WB3FT62A.js} +6 -4
  66. package/dist/{chunk-K63WO3XA.cjs → chunk-WKM6UVMG.cjs} +4 -5
  67. package/dist/{chunk-OS5OT5JA.cjs → chunk-WLEZ2KSG.cjs} +142 -126
  68. package/dist/{chunk-ZN53RM3R.js → chunk-WRGN6UBK.js} +2 -2
  69. package/dist/chunk-WVSPXFTY.js +1 -1
  70. package/dist/{chunk-2VO2CBTU.js → chunk-X6ULJZ3X.js} +2 -2
  71. package/dist/{chunk-CKUEZF4R.cjs → chunk-XYWC4EQ3.cjs} +71 -71
  72. package/dist/{chunk-A3YI6Y2P.js → chunk-YHFRCVTN.js} +3 -3
  73. package/dist/{chunk-RMJC3B5P.cjs → chunk-YQHJB7KR.cjs} +30 -27
  74. package/dist/{chunk-YGB2BQPB.cjs → chunk-YVRUY4EW.cjs} +8 -8
  75. package/dist/chunk-YWHHVDT4.js +1 -1
  76. package/dist/chunk-ZTHJQJ5F.cjs +211 -0
  77. package/dist/conversions/index.cjs +34 -34
  78. package/dist/conversions/index.d.ts +10 -12
  79. package/dist/conversions/index.js +15 -15
  80. package/dist/events/index.cjs +8 -8
  81. package/dist/events/index.d.ts +9 -9
  82. package/dist/events/index.js +4 -4
  83. package/dist/formatters/index.cjs +19 -19
  84. package/dist/formatters/index.d.ts +19 -24
  85. package/dist/formatters/index.js +9 -9
  86. package/dist/generators/index.cjs +12 -8
  87. package/dist/generators/index.d.ts +155 -26
  88. package/dist/generators/index.js +4 -4
  89. package/dist/index.d.ts +1 -1
  90. package/dist/{isPlainObject-FWmcJF6k.d.ts → isPlainObject-BTPjv6zB.d.ts} +2 -2
  91. package/dist/next/index.cjs +39 -36
  92. package/dist/next/index.d.ts +11 -11
  93. package/dist/next/index.js +12 -9
  94. package/dist/next/server/index.cjs +4 -4
  95. package/dist/next/server/index.d.ts +4 -4
  96. package/dist/next/server/index.js +2 -2
  97. package/dist/operations/index.cjs +11 -11
  98. package/dist/operations/index.d.ts +8 -9
  99. package/dist/operations/index.js +8 -8
  100. package/dist/parsers/index.cjs +6 -4
  101. package/dist/parsers/index.d.ts +224 -32
  102. package/dist/parsers/index.js +5 -3
  103. package/dist/predicates/index.cjs +77 -76
  104. package/dist/predicates/index.d.ts +15 -28
  105. package/dist/predicates/index.js +14 -13
  106. package/dist/promises/index.cjs +6 -6
  107. package/dist/promises/index.d.ts +5 -7
  108. package/dist/promises/index.js +4 -4
  109. package/dist/rzl-utils.global.js +2 -2
  110. package/dist/strings/index.cjs +23 -23
  111. package/dist/strings/index.d.ts +1 -1
  112. package/dist/strings/index.js +7 -7
  113. package/dist/tailwind/index.cjs +13 -13
  114. package/dist/tailwind/index.d.ts +18 -18
  115. package/dist/tailwind/index.js +5 -5
  116. package/dist/urls/index.cjs +23 -21
  117. package/dist/urls/index.d.ts +188 -121
  118. package/dist/urls/index.js +16 -14
  119. package/package.json +1 -1
  120. package/dist/chunk-ABA2ZSBQ.js +0 -152
  121. package/dist/chunk-BG3AS5BU.cjs +0 -173
  122. package/dist/chunk-K3SONK25.cjs +0 -157
  123. package/dist/chunk-KPCDDYTZ.js +0 -417
  124. package/dist/chunk-QAPYHLHC.cjs +0 -419
@@ -1,173 +0,0 @@
1
- /*!
2
- * ====================================================
3
- * Rzl Utils-JS.
4
- * ----------------------------------------------------
5
- * Version: 3.7.1.
6
- * Author: Rizalvin Dwiky.
7
- * Repository: https://github.com/rzl-zone/utils-js.
8
- * ====================================================
9
- */
10
- 'use strict';
11
-
12
- var chunkVJVCXEH7_cjs = require('./chunk-VJVCXEH7.cjs');
13
- var chunkLIU4S3JA_cjs = require('./chunk-LIU4S3JA.cjs');
14
- var chunkNREACG6M_cjs = require('./chunk-NREACG6M.cjs');
15
- var chunkYC7AK3KX_cjs = require('./chunk-YC7AK3KX.cjs');
16
- var chunkF3WBQKRI_cjs = require('./chunk-F3WBQKRI.cjs');
17
-
18
- var NormalizePathnameError = class _NormalizePathnameError extends Error {
19
- /** * ***The original error that triggered this normalization failure.***
20
- *
21
- * **Always available for backward compatibility.**
22
- */
23
- originalError;
24
- constructor(message, originalError) {
25
- super(message, chunkF3WBQKRI_cjs.isFunction(Error) ? { cause: originalError } : void 0);
26
- this.name = "NormalizePathnameError";
27
- this.originalError = originalError;
28
- if (chunkF3WBQKRI_cjs.isFunction(Error.captureStackTrace)) {
29
- Error.captureStackTrace(this, _NormalizePathnameError);
30
- } else {
31
- this.stack = new Error(message).stack;
32
- }
33
- }
34
- /** * ***Safe JSON representation for logging or IPC.*** */
35
- toJSON() {
36
- return {
37
- name: this.name,
38
- message: this.message,
39
- stack: this.stack,
40
- originalError: {
41
- name: this.originalError.name,
42
- message: this.originalError.message,
43
- stack: this.originalError.stack
44
- }
45
- };
46
- }
47
- };
48
-
49
- function normalizePathname(pathname, options = {
50
- defaultPath: "/",
51
- keepNullable: false
52
- }) {
53
- chunkF3WBQKRI_cjs.assertIsPlainObject(options, {
54
- message({ currentType, validType }) {
55
- return `Second parameter (\`options\`) must be of type \`${validType}\`, but received: \`${currentType}\`.`;
56
- }
57
- });
58
- const { defaultPath = "/", keepNullable = false, keepTrailingSlash = false } = options;
59
- if (!chunkF3WBQKRI_cjs.isNonEmptyString(defaultPath)) {
60
- throw new TypeError(
61
- `Parameter \`defaultPath\` property of the \`options\` (second parameter) must be of type \`string\` and not empty-string, but received: \`${chunkF3WBQKRI_cjs.getPreciseType(
62
- defaultPath
63
- )}\`, with value: \`${chunkYC7AK3KX_cjs.safeStableStringify(defaultPath)}\`.`
64
- );
65
- }
66
- chunkF3WBQKRI_cjs.assertIsBoolean(keepTrailingSlash, {
67
- message({ currentType, validType }) {
68
- return `Parameter \`keepTrailingSlash\` property of the \`options\` (second parameter) must be of type \`${validType}\`, but received: \`${currentType}\`.`;
69
- }
70
- });
71
- try {
72
- if (keepNullable && (chunkF3WBQKRI_cjs.isNil(pathname) || !chunkF3WBQKRI_cjs.isString(pathname))) {
73
- if (chunkF3WBQKRI_cjs.isNull(pathname)) return null;
74
- return void 0;
75
- }
76
- let currentPathName = chunkF3WBQKRI_cjs.isNonEmptyString(pathname) ? pathname : defaultPath;
77
- currentPathName = chunkLIU4S3JA_cjs.removeSpaces(currentPathName, { trimOnly: true }).replace(
78
- /\s+/g,
79
- ""
80
- );
81
- currentPathName = stripLeadingDomain(currentPathName);
82
- let _pathName = currentPathName;
83
- let search = "";
84
- let hash = "";
85
- const searchIndex = currentPathName.indexOf("?");
86
- const hashIndex = currentPathName.indexOf("#");
87
- if (searchIndex !== -1) {
88
- search = currentPathName.slice(
89
- searchIndex,
90
- hashIndex !== -1 ? hashIndex : void 0
91
- );
92
- }
93
- if (hashIndex !== -1) {
94
- hash = currentPathName.slice(hashIndex);
95
- }
96
- const endIndex = Math.min(
97
- searchIndex !== -1 ? searchIndex : currentPathName.length,
98
- hashIndex !== -1 ? hashIndex : currentPathName.length
99
- );
100
- _pathName = currentPathName.slice(0, endIndex);
101
- _pathName = "/" + _pathName.replace(/^\/+/, "").replace(/\/{2,}/g, "/");
102
- if (!keepTrailingSlash && _pathName !== "/") {
103
- _pathName = _pathName.replace(/\/+$/, "");
104
- }
105
- _pathName = decodeUnicodeSequences(_pathName);
106
- search = decodeUnicodeSequences(search);
107
- hash = decodeUnicodeSequences(hash);
108
- return _pathName + search + hash;
109
- } catch (error) {
110
- const err = chunkF3WBQKRI_cjs.isError(error) ? error : new Error("Unknown error from function `normalizePathname()`.");
111
- throw new NormalizePathnameError(
112
- `Failed to normalize pathname in function \`normalizePathname()\`: ${err.message}`,
113
- err
114
- );
115
- }
116
- }
117
- function decodeUnicodeSequences(str) {
118
- return str.replace(/(?:%(?:[0-9A-F]{2})){2,}/gi, (match) => {
119
- try {
120
- const decoded = decodeURIComponent(match);
121
- if (/^[\u0000-\u007F]+$/.test(decoded)) return match;
122
- return decoded;
123
- } catch {
124
- return match;
125
- }
126
- });
127
- }
128
- function stripLeadingDomain(path) {
129
- let currentPath = path;
130
- if (/^https?:\/\//i.test(currentPath)) {
131
- try {
132
- const url = new URL(currentPath);
133
- currentPath = "/" + url.pathname.replace(/^\/+/, "").replace(/\/{2,}/g, "/") + url.search + url.hash;
134
- } catch {
135
- }
136
- }
137
- if (currentPath.startsWith("/")) {
138
- currentPath = currentPath.replace(/\/{2,}/g, "/").slice(1);
139
- }
140
- const firstPart = currentPath.split("/")[0];
141
- const domainPart = firstPart.split(":")[0];
142
- if (chunkVJVCXEH7_cjs.isValidDomain(domainPart, {
143
- subdomain: true,
144
- allowUnicode: true,
145
- wildcard: true,
146
- topLevel: false
147
- }) || domainPart === "localhost") {
148
- currentPath = currentPath.slice(firstPart.length);
149
- }
150
- if (!currentPath.startsWith("/")) currentPath = "/" + currentPath;
151
- return currentPath;
152
- }
153
-
154
- var formatEnvPort = (envVar, options = {}) => {
155
- if (!chunkF3WBQKRI_cjs.isNonEmptyString(envVar)) return "";
156
- chunkF3WBQKRI_cjs.assertIsPlainObject(options, {
157
- message: ({ currentType, validType }) => `Second parameter (\`options\`) must be of type \`${validType}\`, but received: \`${currentType}\`.`
158
- });
159
- const prefixColon = chunkF3WBQKRI_cjs.hasOwnProp(options, "prefixColon") ? options.prefixColon : false;
160
- if (!chunkF3WBQKRI_cjs.isBoolean(prefixColon)) {
161
- throw new TypeError(
162
- `Parameter \`prefixColon\` property of the \`options\` (second parameter) must be of type \`boolean\`, but received: \`${chunkF3WBQKRI_cjs.getPreciseType(
163
- prefixColon
164
- )}\`.`
165
- );
166
- }
167
- const digitsOnly = envVar.replace(/\D+/g, "");
168
- if (chunkNREACG6M_cjs.isEmptyString(digitsOnly)) return "";
169
- return prefixColon ? `:${digitsOnly}` : digitsOnly;
170
- };
171
-
172
- exports.formatEnvPort = formatEnvPort;
173
- exports.normalizePathname = normalizePathname;
@@ -1,157 +0,0 @@
1
- /*!
2
- * ====================================================
3
- * Rzl Utils-JS.
4
- * ----------------------------------------------------
5
- * Version: 3.7.1.
6
- * Author: Rizalvin Dwiky.
7
- * Repository: https://github.com/rzl-zone/utils-js.
8
- * ====================================================
9
- */
10
- 'use strict';
11
-
12
- var chunkDVMHRLKP_cjs = require('./chunk-DVMHRLKP.cjs');
13
- var chunkYC7AK3KX_cjs = require('./chunk-YC7AK3KX.cjs');
14
- var chunkF3WBQKRI_cjs = require('./chunk-F3WBQKRI.cjs');
15
-
16
- function getRandomItem(array) {
17
- if (!chunkF3WBQKRI_cjs.isNonEmptyArray(array)) return void 0;
18
- const randomIndex = Math.floor(Math.random() * (array.length || 0));
19
- return array[randomIndex];
20
- }
21
-
22
- var randomInt = (min, max) => {
23
- if (!chunkDVMHRLKP_cjs.isInteger(min) || !chunkDVMHRLKP_cjs.isInteger(max)) {
24
- throw new TypeError(
25
- `First parameter (\`min\`) and second parameter (\`max\`) must be of type \`integer-number\`${minValueNote(
26
- min,
27
- max
28
- )}value, but received: ['min': \`${chunkF3WBQKRI_cjs.getPreciseType(
29
- min
30
- )}\` - (with value: \`${chunkYC7AK3KX_cjs.safeStableStringify(min)})\`, 'max': \`${chunkF3WBQKRI_cjs.getPreciseType(
31
- max
32
- )}\` - (with value: \`${chunkYC7AK3KX_cjs.safeStableStringify(max)}\`)].`
33
- );
34
- }
35
- if (min > max) {
36
- throw new RangeError(
37
- `First parameter (\`min\`) must be less than or equal to second parameter (\`max\`), but received: ['min': ${formatValue(
38
- min
39
- )}, 'max': ${formatValue(max)}].`
40
- );
41
- }
42
- min = Math.max(1, min);
43
- max = Math.min(Number.MAX_SAFE_INTEGER, max);
44
- return Math.floor(Math.random() * (max - min + 1)) + min;
45
- };
46
- var formatValue = (value) => {
47
- return chunkF3WBQKRI_cjs.isNumber(value, { includeNaN: true }) ? value === Number.MIN_VALUE ? "`Number.MIN_VALUE`" : `${value}` : `\`${chunkF3WBQKRI_cjs.getPreciseType(value)}\``;
48
- };
49
- var minValueNote = (...values) => {
50
- return values.some((v) => chunkF3WBQKRI_cjs.isNumber(v, { includeNaN: true }) && v === Number.MIN_VALUE) ? " and can't be `Number.MIN_VALUE` " : " ";
51
- };
52
-
53
- var randomIntByLength = (options) => {
54
- if (!chunkF3WBQKRI_cjs.isPlainObject(options)) {
55
- options = {};
56
- }
57
- const { minLength = 1, maxLength = 16, avoidZero = false } = options;
58
- chunkF3WBQKRI_cjs.assertIsBoolean(avoidZero, {
59
- message({ currentType, validType }) {
60
- return `Parameters \`avoidZero\` must be of type \`${validType}\`, but received: \`${currentType}\`.`;
61
- }
62
- });
63
- if (!chunkDVMHRLKP_cjs.isInteger(minLength) || !chunkDVMHRLKP_cjs.isInteger(maxLength)) {
64
- throw new TypeError(
65
- `Parameters \`minLength\` and \`maxLength\` must be of type \`integer-number\`, but received: ['minLength': \`${chunkF3WBQKRI_cjs.getPreciseType(
66
- minLength
67
- )}\` - (with value: ${chunkYC7AK3KX_cjs.safeStableStringify(
68
- minLength
69
- )}), 'maxLength': \`${chunkF3WBQKRI_cjs.getPreciseType(
70
- maxLength
71
- )}\` - (with value: ${chunkYC7AK3KX_cjs.safeStableStringify(maxLength)})].`
72
- );
73
- }
74
- if (minLength < 1 || maxLength > 16 || minLength > maxLength) {
75
- throw new RangeError(
76
- `Invalid range at parameters \`minLength\` must be \u2265 1, \`maxLength\` must be \u2264 16, and \`minLength\` \u2264 \`maxLength\`, but received: ['minLength': \`${minLength}\`, 'maxLength': \`${maxLength}\`].`
77
- );
78
- }
79
- const randomLength = minLength === maxLength ? minLength : randomInt(minLength, maxLength);
80
- const minValue = 10 ** (randomLength - 1);
81
- const maxValue = 10 ** randomLength - 1;
82
- let result = randomInt(minValue, maxValue);
83
- if (avoidZero && result === 0) {
84
- result = minValue;
85
- }
86
- return result;
87
- };
88
-
89
- var randomStr = (options) => {
90
- if (!chunkF3WBQKRI_cjs.isPlainObject(options)) {
91
- options = {};
92
- }
93
- const {
94
- minLength = 40,
95
- maxLength = 40,
96
- type = "string",
97
- avoidWhiteSpace = true
98
- } = options;
99
- chunkF3WBQKRI_cjs.assertIsBoolean(avoidWhiteSpace, {
100
- message({ currentType, validType }) {
101
- return `Parameters \`avoidWhiteSpace\` property of the \`options\` (first-parameter) must be of type \`${validType}\`, but received: \`${currentType}\`.`;
102
- }
103
- });
104
- if (!chunkDVMHRLKP_cjs.isInteger(minLength) || !chunkDVMHRLKP_cjs.isInteger(maxLength)) {
105
- throw new TypeError(
106
- `Parameters \`minLength\` and \`maxLength\` must be of type \`integer-number\`, but received: ['minLength': \`${chunkF3WBQKRI_cjs.getPreciseType(
107
- minLength
108
- )}\` - (with value: ${chunkYC7AK3KX_cjs.safeStableStringify(
109
- minLength
110
- )}), 'maxLength': \`${chunkF3WBQKRI_cjs.getPreciseType(
111
- maxLength
112
- )}\` - (with value: ${chunkYC7AK3KX_cjs.safeStableStringify(maxLength)})].`
113
- );
114
- }
115
- if (minLength < 1 || maxLength > 5e3 || minLength > maxLength) {
116
- throw new RangeError(
117
- `Invalid range at parameters \`minLength\` must be \u2265 1, \`maxLength\` must be \u2264 5000, and \`minLength\` \u2264 \`maxLength\`, but received: ['minLength': \`${minLength}\`, 'maxLength': \`${maxLength}\`].`
118
- );
119
- }
120
- if (type !== "string" && type !== "number") {
121
- throw new TypeError(
122
- `Parameter \`type\` must be of type \`string\` with value one of "string" | "number", but received: \`${chunkF3WBQKRI_cjs.getPreciseType(
123
- type
124
- )}\`, with value: ${chunkYC7AK3KX_cjs.safeStableStringify(type)}.`
125
- );
126
- }
127
- const length = randomInt(minLength, maxLength);
128
- const cleanCharacters = (charSet) => {
129
- return avoidWhiteSpace ? charSet.replace(/\s|\n|\t/g, "") : charSet;
130
- };
131
- const defaultNumberSet = "0123456789";
132
- const defaultStringSet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
133
- const baseCharSet = type === "number" ? (!chunkF3WBQKRI_cjs.isNaN(Number(options.replaceGenInt)) ? options.replaceGenInt : void 0) ?? defaultNumberSet : (options.replaceGenStr ? options.replaceGenStr : void 0) ?? defaultStringSet;
134
- const characterSet = cleanCharacters(baseCharSet) + (options.addChar || "");
135
- if (!characterSet.length) {
136
- const errCharSet = () => {
137
- if (type === "number") {
138
- if (avoidWhiteSpace) {
139
- return `If \`avoidWhiteSpace\` is true, and \`replaceGenInt\` cant be empty-string value, ensure \`replaceGenInt\` has valid characters and non-nan string number.`;
140
- }
141
- return `Ensure \`replaceGenInt\` has valid characters and not a NaN number string while convert to number.`;
142
- }
143
- return `Ensure \`replaceGenStr\` has valid characters and non empty string.`;
144
- };
145
- throw new Error(`Character set is empty. ${errCharSet()}`);
146
- }
147
- let result = "";
148
- for (let i = 0; i < length; i++) {
149
- result += characterSet.charAt(Math.floor(Math.random() * characterSet.length));
150
- }
151
- return result;
152
- };
153
-
154
- exports.getRandomItem = getRandomItem;
155
- exports.randomInt = randomInt;
156
- exports.randomIntByLength = randomIntByLength;
157
- exports.randomStr = randomStr;