@rzl-zone/utils-js 3.5.3 → 3.5.5
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/dist/assertions/index.cjs +11 -11
- package/dist/assertions/index.d.ts +1 -1
- package/dist/assertions/index.js +5 -5
- package/dist/{chunk-RZW35UN5.cjs → chunk-2CQI36UD.cjs} +6 -6
- package/dist/{chunk-PET42Z7W.js → chunk-2VO2CBTU.js} +2 -2
- package/dist/{chunk-CMW2TBOQ.js → chunk-3KTD3QDI.js} +2 -7
- package/dist/{chunk-XEDXFSGI.js → chunk-4ACKNPL5.js} +2 -2
- package/dist/{chunk-SIM77PU4.js → chunk-4ZOXSUXB.js} +3 -3
- package/dist/{chunk-IVL7CKVH.cjs → chunk-5NN4ZDE2.cjs} +6 -6
- package/dist/{chunk-FJZGG54N.cjs → chunk-66WLOZOD.cjs} +50 -50
- package/dist/{chunk-SBFNXGTJ.js → chunk-6DSPJA5U.js} +9 -9
- package/dist/{chunk-D3ENH7H6.cjs → chunk-6RFNZ2ZZ.cjs} +14 -14
- package/dist/{chunk-CKTLUNWX.js → chunk-6WMB5AJR.js} +2 -2
- package/dist/{chunk-JBQMXC5I.cjs → chunk-7QQV66RX.cjs} +10 -10
- package/dist/{chunk-6JFZL7YE.cjs → chunk-7WBMA2VE.cjs} +4 -4
- package/dist/{chunk-3IBQ5MOM.js → chunk-7ZNEUWYP.js} +2 -2
- package/dist/{chunk-JEQEF5WD.js → chunk-A3YI6Y2P.js} +3 -3
- package/dist/{chunk-DEZZUYE2.js → chunk-ABA2ZSBQ.js} +3 -3
- package/dist/{chunk-NRF6LWBC.cjs → chunk-AKKM6MOX.cjs} +15 -15
- package/dist/{chunk-ZETAZZLD.cjs → chunk-ATLFMKAF.cjs} +7 -7
- package/dist/{chunk-V45XJKHW.cjs → chunk-B4SDEBN7.cjs} +3 -3
- package/dist/{chunk-2IOOEY45.cjs → chunk-B6UIKBHR.cjs} +4 -4
- package/dist/chunk-BAV5T2E3.cjs +1 -1
- package/dist/{chunk-E74U6CYP.cjs → chunk-BYUT376O.cjs} +3 -3
- package/dist/{chunk-OYTYSY7G.js → chunk-D53CE4BT.js} +7 -7
- package/dist/{chunk-IRFL4MAX.js → chunk-DPLL67OT.js} +2 -2
- package/dist/chunk-DVMHRLKP.cjs +1 -1
- package/dist/{chunk-5KJFVIQT.cjs → chunk-EK7FSI7F.cjs} +3 -3
- package/dist/{chunk-PZQ6I4JJ.cjs → chunk-F3WBQKRI.cjs} +1 -8
- package/dist/{chunk-SBKGWRS5.js → chunk-FI76UZRF.js} +2 -2
- package/dist/{chunk-IZPBKKPO.js → chunk-GAJBF6DR.js} +2 -2
- package/dist/{chunk-DWF2R5GD.cjs → chunk-H5NWBTHW.cjs} +61 -61
- package/dist/{chunk-W2WNBUDE.js → chunk-JY4HLZ4W.js} +2 -2
- package/dist/{chunk-5757UBXJ.cjs → chunk-K3SONK25.cjs} +24 -24
- package/dist/{chunk-HYRQMTRH.cjs → chunk-K63WO3XA.cjs} +4 -4
- package/dist/chunk-KHO2SBNA.cjs +1 -1
- package/dist/{chunk-RIPKY4RU.js → chunk-KPCDDYTZ.js} +2 -2
- package/dist/{chunk-F6IPNNSJ.cjs → chunk-KTQLDIIT.cjs} +161 -161
- package/dist/chunk-L5RDAVVH.js +1 -1
- package/dist/{chunk-GGEADHZO.js → chunk-LBNOZIZ6.js} +5 -5
- package/dist/{chunk-3VA554KW.js → chunk-LEX4TQW2.js} +2 -2
- package/dist/{chunk-KVAL5PAG.cjs → chunk-LIU4S3JA.cjs} +4 -4
- package/dist/{chunk-E55EQK2U.cjs → chunk-NREACG6M.cjs} +3 -3
- package/dist/{chunk-T2T7K3KR.js → chunk-OFBFGFVH.js} +2 -2
- package/dist/chunk-ONZFBJVW.js +1 -1
- package/dist/{chunk-XABCB3Y7.cjs → chunk-OS5OT5JA.cjs} +126 -126
- package/dist/{chunk-GQR4R5WY.js → chunk-PZQC3FZY.js} +4 -4
- package/dist/{chunk-FWHNWL2P.cjs → chunk-QAPYHLHC.cjs} +3 -3
- package/dist/chunk-QNKGP5DY.js +1 -1
- package/dist/{chunk-YKPSRP5G.js → chunk-QUITZ3GP.js} +8 -8
- package/dist/{chunk-7ODAAXX5.cjs → chunk-RIEYB2AW.cjs} +71 -71
- package/dist/{chunk-LS6U7FAY.cjs → chunk-RMJC3B5P.cjs} +26 -26
- package/dist/{chunk-CDCERIZ2.js → chunk-RS5RBLPB.js} +31 -4
- package/dist/{chunk-JMJQCN74.js → chunk-SN6YRDLG.js} +9 -9
- package/dist/{chunk-NBZWMBO6.js → chunk-SZJ7OI4S.js} +3 -3
- package/dist/{chunk-FWCKOJZM.js → chunk-TDPYR5JY.js} +10 -10
- package/dist/{chunk-OI5XKNZO.js → chunk-TDYGYHSH.js} +4 -4
- package/dist/{chunk-CAH33WOQ.cjs → chunk-TFDXRT6D.cjs} +3 -3
- package/dist/{chunk-2WA36TC5.cjs → chunk-TPYENEQ4.cjs} +50 -23
- package/dist/chunk-UDA26MCU.cjs +1 -1
- package/dist/{chunk-HQWOFR56.cjs → chunk-UKAUXY2U.cjs} +12 -12
- package/dist/{chunk-H66AC7GK.cjs → chunk-URDI3IMY.cjs} +19 -19
- package/dist/{chunk-6JFCSH7J.js → chunk-VCVND6CH.js} +2 -2
- package/dist/chunk-VJDDGRIK.cjs +1 -1
- package/dist/{chunk-QBKAEVYG.js → chunk-VNADVWSJ.js} +3 -3
- package/dist/chunk-WVSPXFTY.js +1 -1
- package/dist/{chunk-2CQX5CBG.js → chunk-XFTUHS4Y.js} +4 -4
- package/dist/{chunk-T7PU2V7X.cjs → chunk-YC7AK3KX.cjs} +31 -31
- package/dist/{chunk-EL6A35UR.cjs → chunk-YGB2BQPB.cjs} +8 -8
- package/dist/chunk-YWHHVDT4.js +1 -1
- package/dist/{chunk-5IGC6PBH.js → chunk-ZN53RM3R.js} +2 -2
- package/dist/conversions/index.cjs +34 -34
- package/dist/conversions/index.d.ts +1 -1
- package/dist/conversions/index.js +15 -15
- package/dist/events/index.cjs +8 -8
- package/dist/events/index.d.ts +1 -1
- package/dist/events/index.js +4 -4
- package/dist/formatters/index.cjs +19 -19
- package/dist/formatters/index.d.ts +1 -1
- package/dist/formatters/index.js +9 -9
- package/dist/generators/index.cjs +8 -8
- package/dist/generators/index.d.ts +1 -1
- package/dist/generators/index.js +4 -4
- package/dist/index.d.ts +1 -14
- package/dist/isPlainObject-FWmcJF6k.d.ts +1 -1
- package/dist/next/index.cjs +35 -35
- package/dist/next/index.d.ts +1 -1
- package/dist/next/index.js +7 -7
- package/dist/next/server/index.cjs +4 -4
- package/dist/next/server/index.d.ts +1 -1
- package/dist/next/server/index.js +2 -2
- package/dist/operations/index.cjs +11 -11
- package/dist/operations/index.d.ts +1 -1
- package/dist/operations/index.js +8 -8
- package/dist/parsers/index.cjs +4 -4
- package/dist/parsers/index.d.ts +1 -1
- package/dist/parsers/index.js +3 -3
- package/dist/predicates/index.cjs +74 -82
- package/dist/predicates/index.d.ts +2 -23
- package/dist/predicates/index.js +12 -12
- package/dist/promises/index.cjs +6 -6
- package/dist/promises/index.d.ts +1 -1
- package/dist/promises/index.js +4 -4
- package/dist/rzl-utils.global.js +2 -17
- package/dist/strings/index.cjs +23 -23
- package/dist/strings/index.d.ts +1 -1
- package/dist/strings/index.js +7 -7
- package/dist/tailwind/index.cjs +12 -11
- package/dist/tailwind/index.d.ts +6 -17
- package/dist/tailwind/index.js +5 -4
- package/dist/urls/index.cjs +19 -19
- package/dist/urls/index.d.ts +1 -1
- package/dist/urls/index.js +13 -13
- package/package.json +1 -1
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* ====================================================
|
|
3
3
|
* Rzl Utils-JS.
|
|
4
4
|
* ----------------------------------------------------
|
|
5
|
-
* Version: 3.5.
|
|
5
|
+
* Version: 3.5.5.
|
|
6
6
|
* Author: Rizalvin Dwiky.
|
|
7
7
|
* Repository: https://github.com/rzl-zone/utils-js.
|
|
8
8
|
* ====================================================
|
|
@@ -10,64 +10,64 @@
|
|
|
10
10
|
'use strict';
|
|
11
11
|
|
|
12
12
|
var chunkKHO2SBNA_cjs = require('./chunk-KHO2SBNA.cjs');
|
|
13
|
-
var
|
|
14
|
-
var
|
|
15
|
-
var
|
|
13
|
+
var chunkBYUT376O_cjs = require('./chunk-BYUT376O.cjs');
|
|
14
|
+
var chunkAKKM6MOX_cjs = require('./chunk-AKKM6MOX.cjs');
|
|
15
|
+
var chunkUKAUXY2U_cjs = require('./chunk-UKAUXY2U.cjs');
|
|
16
16
|
var chunkDVMHRLKP_cjs = require('./chunk-DVMHRLKP.cjs');
|
|
17
|
-
var
|
|
18
|
-
var
|
|
19
|
-
var
|
|
20
|
-
var
|
|
21
|
-
var
|
|
17
|
+
var chunkURDI3IMY_cjs = require('./chunk-URDI3IMY.cjs');
|
|
18
|
+
var chunkNREACG6M_cjs = require('./chunk-NREACG6M.cjs');
|
|
19
|
+
var chunk7WBMA2VE_cjs = require('./chunk-7WBMA2VE.cjs');
|
|
20
|
+
var chunkYC7AK3KX_cjs = require('./chunk-YC7AK3KX.cjs');
|
|
21
|
+
var chunkF3WBQKRI_cjs = require('./chunk-F3WBQKRI.cjs');
|
|
22
22
|
|
|
23
23
|
var constructURL = (baseUrl, queryParams, removeParams) => {
|
|
24
|
-
if (
|
|
25
|
-
if (
|
|
24
|
+
if (chunkF3WBQKRI_cjs.isString(baseUrl)) {
|
|
25
|
+
if (chunkNREACG6M_cjs.isEmptyString(baseUrl)) {
|
|
26
26
|
throw new TypeError(`First parameter (\`baseUrl\`) cannot be an empty-string.`);
|
|
27
27
|
}
|
|
28
|
-
baseUrl =
|
|
28
|
+
baseUrl = chunkBYUT376O_cjs.normalizeString(baseUrl);
|
|
29
29
|
} else if (!chunkKHO2SBNA_cjs.isURL(baseUrl)) {
|
|
30
30
|
throw new TypeError(
|
|
31
|
-
`First parameter (\`baseUrl\`) must be of type an URL instance or a \`string\` and a non empty-string, but received: \`${
|
|
31
|
+
`First parameter (\`baseUrl\`) must be of type an URL instance or a \`string\` and a non empty-string, but received: \`${chunkF3WBQKRI_cjs.getPreciseType(
|
|
32
32
|
baseUrl
|
|
33
|
-
)}\`, with current value: \`${
|
|
33
|
+
)}\`, with current value: \`${chunkYC7AK3KX_cjs.safeStableStringify(baseUrl)}\`.`
|
|
34
34
|
);
|
|
35
35
|
}
|
|
36
|
-
if (!
|
|
37
|
-
|
|
36
|
+
if (!chunkF3WBQKRI_cjs.isUndefined(removeParams)) {
|
|
37
|
+
chunk7WBMA2VE_cjs.assertIsArray(removeParams, {
|
|
38
38
|
message: ({ currentType, validType }) => `Third parameter (\`removeParams\`) must be of type \`${validType} of strings\`, but received: \`${currentType}\`.`
|
|
39
39
|
});
|
|
40
|
-
if (!removeParams.every((param) =>
|
|
40
|
+
if (!removeParams.every((param) => chunkF3WBQKRI_cjs.isNonEmptyString(param))) {
|
|
41
41
|
throw new TypeError(
|
|
42
42
|
`Third parameter (\`removeParams\`) must be of type \`array\` and contains \`string\` only and non empty-string.`
|
|
43
43
|
);
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
try {
|
|
47
|
-
if (!
|
|
47
|
+
if (!chunkF3WBQKRI_cjs.isUndefined(queryParams) && !chunkF3WBQKRI_cjs.isFunction(queryParams[Symbol.iterator])) {
|
|
48
48
|
throw new TypeError(
|
|
49
|
-
`Second parameter (\`queryParams\`) must be iterable (like URLSearchParams.entries() or an array of [[string, string | number]...]), but received: \`${
|
|
49
|
+
`Second parameter (\`queryParams\`) must be iterable (like URLSearchParams.entries() or an array of [[string, string | number]...]), but received: \`${chunkF3WBQKRI_cjs.getPreciseType(
|
|
50
50
|
queryParams
|
|
51
|
-
)}\`, with value: \`${
|
|
51
|
+
)}\`, with value: \`${chunkYC7AK3KX_cjs.safeStableStringify(queryParams)}\`.`
|
|
52
52
|
);
|
|
53
53
|
}
|
|
54
54
|
const urlInstance = new URL(baseUrl);
|
|
55
|
-
if (!
|
|
55
|
+
if (!chunkF3WBQKRI_cjs.isUndefined(queryParams)) {
|
|
56
56
|
const paramObject = Object.fromEntries(queryParams);
|
|
57
|
-
if (!
|
|
57
|
+
if (!chunkUKAUXY2U_cjs.isEmptyValue(paramObject)) {
|
|
58
58
|
const mergedParams = new URLSearchParams(urlInstance.search);
|
|
59
59
|
for (const [key, value] of Object.entries(paramObject)) {
|
|
60
|
-
if (!
|
|
60
|
+
if (!chunkF3WBQKRI_cjs.isNonEmptyString(value) && !chunkF3WBQKRI_cjs.isNumber(value, { includeNaN: true })) {
|
|
61
61
|
throw new TypeError(
|
|
62
|
-
`Second parameter (\`queryParams\`) must be iterable (like URLSearchParams.entries() or an array of [[string, string | number]...]), but received: \`${
|
|
62
|
+
`Second parameter (\`queryParams\`) must be iterable (like URLSearchParams.entries() or an array of [[string, string | number]...]), but received: \`${chunkF3WBQKRI_cjs.getPreciseType(
|
|
63
63
|
queryParams
|
|
64
|
-
)}\`, with value: \`${
|
|
64
|
+
)}\`, with value: \`${chunkYC7AK3KX_cjs.safeStableStringify(queryParams)}\`.`
|
|
65
65
|
);
|
|
66
66
|
}
|
|
67
67
|
mergedParams.set(key, String(value));
|
|
68
68
|
}
|
|
69
69
|
if (removeParams?.length) {
|
|
70
|
-
|
|
70
|
+
chunkAKKM6MOX_cjs.toStringArrayUnRecursive(removeParams).map((paramKey) => {
|
|
71
71
|
mergedParams.delete(paramKey);
|
|
72
72
|
});
|
|
73
73
|
}
|
|
@@ -77,7 +77,7 @@ var constructURL = (baseUrl, queryParams, removeParams) => {
|
|
|
77
77
|
removeParams?.forEach((param) => urlInstance.searchParams.delete(param));
|
|
78
78
|
return urlInstance;
|
|
79
79
|
} catch (error) {
|
|
80
|
-
if (
|
|
80
|
+
if (chunkF3WBQKRI_cjs.isError(error)) throw error;
|
|
81
81
|
throw new Error(
|
|
82
82
|
"Failed to construct a valid URL in `constructURL()`, Error:" + error
|
|
83
83
|
);
|
|
@@ -85,7 +85,7 @@ var constructURL = (baseUrl, queryParams, removeParams) => {
|
|
|
85
85
|
};
|
|
86
86
|
|
|
87
87
|
var extractURLs = (url) => {
|
|
88
|
-
if (!
|
|
88
|
+
if (!chunkF3WBQKRI_cjs.isNonEmptyString(url)) return null;
|
|
89
89
|
let decoded;
|
|
90
90
|
try {
|
|
91
91
|
decoded = decodeURIComponent(url);
|
|
@@ -107,62 +107,62 @@ var extractURLs = (url) => {
|
|
|
107
107
|
};
|
|
108
108
|
|
|
109
109
|
var getFirstPrefixPathname = (result, defaultValue = "/") => {
|
|
110
|
-
if (!
|
|
110
|
+
if (!chunkF3WBQKRI_cjs.isNonEmptyString(defaultValue)) {
|
|
111
111
|
throw new TypeError(
|
|
112
|
-
`Second parameter (\`defaultValue\`) must be of type \`string\` and not an \`empty-string\`, but received: \`${
|
|
112
|
+
`Second parameter (\`defaultValue\`) must be of type \`string\` and not an \`empty-string\`, but received: \`${chunkF3WBQKRI_cjs.getPreciseType(
|
|
113
113
|
defaultValue
|
|
114
|
-
)}\`, with value: \`${
|
|
114
|
+
)}\`, with value: \`${chunkYC7AK3KX_cjs.safeStableStringify(defaultValue)}\`.`
|
|
115
115
|
);
|
|
116
116
|
}
|
|
117
|
-
if (
|
|
118
|
-
if (!result.every((item) =>
|
|
117
|
+
if (chunkF3WBQKRI_cjs.isArray(result)) {
|
|
118
|
+
if (!result.every((item) => chunkF3WBQKRI_cjs.isString(item))) {
|
|
119
119
|
throw new TypeError(
|
|
120
|
-
`First parameter (\`result\`) must be of type \`string\` or \`array of string\`, but received: \`${
|
|
120
|
+
`First parameter (\`result\`) must be of type \`string\` or \`array of string\`, but received: \`${chunkF3WBQKRI_cjs.getPreciseType(
|
|
121
121
|
result
|
|
122
|
-
)}\`, with value: \`${
|
|
122
|
+
)}\`, with value: \`${chunkYC7AK3KX_cjs.safeStableStringify(result)}\`.`
|
|
123
123
|
);
|
|
124
124
|
}
|
|
125
125
|
for (const item of result) {
|
|
126
|
-
const normalized =
|
|
126
|
+
const normalized = chunkURDI3IMY_cjs.normalizePathname(item);
|
|
127
127
|
if (normalized !== "/") {
|
|
128
128
|
return normalized;
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
|
-
return
|
|
131
|
+
return chunkURDI3IMY_cjs.normalizePathname(defaultValue);
|
|
132
132
|
}
|
|
133
|
-
if (
|
|
134
|
-
const normalized =
|
|
135
|
-
return normalized !== "/" ? normalized :
|
|
133
|
+
if (chunkF3WBQKRI_cjs.isString(result)) {
|
|
134
|
+
const normalized = chunkURDI3IMY_cjs.normalizePathname(result);
|
|
135
|
+
return normalized !== "/" ? normalized : chunkURDI3IMY_cjs.normalizePathname(defaultValue);
|
|
136
136
|
}
|
|
137
|
-
if (!
|
|
137
|
+
if (!chunkF3WBQKRI_cjs.isNil(result)) {
|
|
138
138
|
throw new TypeError(
|
|
139
|
-
`First parameter (\`result\`) must be of type \`string\`, \`array-string\`, \`null\` or \`undefined\`, but received: \`${
|
|
139
|
+
`First parameter (\`result\`) must be of type \`string\`, \`array-string\`, \`null\` or \`undefined\`, but received: \`${chunkF3WBQKRI_cjs.getPreciseType(
|
|
140
140
|
result
|
|
141
141
|
)}\`.`
|
|
142
142
|
);
|
|
143
143
|
}
|
|
144
|
-
return
|
|
144
|
+
return chunkURDI3IMY_cjs.normalizePathname(defaultValue);
|
|
145
145
|
};
|
|
146
146
|
|
|
147
147
|
var getPrefixPathname = (url, base = null, options = {}) => {
|
|
148
148
|
const errors = [];
|
|
149
|
-
if (!
|
|
149
|
+
if (!chunkF3WBQKRI_cjs.isString(url) && !chunkF3WBQKRI_cjs.isArray(url)) {
|
|
150
150
|
errors.push(
|
|
151
|
-
`First parameter (\`url\`) must be of type \`string\` or \`array-string\`, but received: \`${
|
|
151
|
+
`First parameter (\`url\`) must be of type \`string\` or \`array-string\`, but received: \`${chunkF3WBQKRI_cjs.getPreciseType(
|
|
152
152
|
url
|
|
153
153
|
)}\`.`
|
|
154
154
|
);
|
|
155
155
|
}
|
|
156
|
-
if (!
|
|
156
|
+
if (!chunkF3WBQKRI_cjs.isString(base) && !chunkF3WBQKRI_cjs.isArray(base) && !chunkF3WBQKRI_cjs.isNull(base)) {
|
|
157
157
|
errors.push(
|
|
158
|
-
`Second parameter (\`base\`) must be of type \`string\`, \`array-string\` or \`null\`, but received: \`${
|
|
158
|
+
`Second parameter (\`base\`) must be of type \`string\`, \`array-string\` or \`null\`, but received: \`${chunkF3WBQKRI_cjs.getPreciseType(
|
|
159
159
|
base
|
|
160
160
|
)}\`.`
|
|
161
161
|
);
|
|
162
162
|
}
|
|
163
|
-
if (!
|
|
163
|
+
if (!chunkF3WBQKRI_cjs.isPlainObject(options)) {
|
|
164
164
|
errors.push(
|
|
165
|
-
`Second parameter (\`options\`) must be of type \`plain-object\`, but received: \`${
|
|
165
|
+
`Second parameter (\`options\`) must be of type \`plain-object\`, but received: \`${chunkF3WBQKRI_cjs.getPreciseType(
|
|
166
166
|
options
|
|
167
167
|
)}\`.`
|
|
168
168
|
);
|
|
@@ -170,46 +170,46 @@ var getPrefixPathname = (url, base = null, options = {}) => {
|
|
|
170
170
|
const { levels = 1, removeDuplicates = true } = options;
|
|
171
171
|
if (!chunkDVMHRLKP_cjs.isInteger(levels) || chunkDVMHRLKP_cjs.isInteger(levels) && levels < 0) {
|
|
172
172
|
errors.push(
|
|
173
|
-
`Parameter \`levels\` property of the \`options\` (second parameter) must be of type \`integer-number\` and minimum is \`0\`, but received: \`${
|
|
173
|
+
`Parameter \`levels\` property of the \`options\` (second parameter) must be of type \`integer-number\` and minimum is \`0\`, but received: \`${chunkF3WBQKRI_cjs.getPreciseType(
|
|
174
174
|
levels
|
|
175
|
-
)}\`, with value: \`${
|
|
175
|
+
)}\`, with value: \`${chunkYC7AK3KX_cjs.safeStableStringify(levels)}\`.`
|
|
176
176
|
);
|
|
177
177
|
}
|
|
178
|
-
if (!
|
|
178
|
+
if (!chunkF3WBQKRI_cjs.isBoolean(removeDuplicates)) {
|
|
179
179
|
errors.push(
|
|
180
|
-
`Parameter \`removeDuplicates\` property of the \`options\` (second parameter) must be of type \`boolean\`, but received: \`${
|
|
180
|
+
`Parameter \`removeDuplicates\` property of the \`options\` (second parameter) must be of type \`boolean\`, but received: \`${chunkF3WBQKRI_cjs.getPreciseType(
|
|
181
181
|
removeDuplicates
|
|
182
182
|
)}\`.`
|
|
183
183
|
);
|
|
184
184
|
}
|
|
185
|
-
if (
|
|
185
|
+
if (chunkF3WBQKRI_cjs.isNonEmptyArray(errors)) {
|
|
186
186
|
throw new TypeError(
|
|
187
187
|
`Invalid parameter(s) in \`getPrefixPathname\` function:
|
|
188
188
|
- ${errors.join("\n- ")}`
|
|
189
189
|
);
|
|
190
190
|
}
|
|
191
191
|
function getLevel(singleUrl) {
|
|
192
|
-
const parts =
|
|
192
|
+
const parts = chunkURDI3IMY_cjs.normalizePathname(singleUrl).split("/").filter(Boolean);
|
|
193
193
|
return `/${parts.slice(0, levels).join("/")}`;
|
|
194
194
|
}
|
|
195
195
|
function processUrl(singleUrl) {
|
|
196
196
|
if (base) {
|
|
197
|
-
singleUrl =
|
|
198
|
-
if (
|
|
197
|
+
singleUrl = chunkURDI3IMY_cjs.normalizePathname(singleUrl);
|
|
198
|
+
if (chunkF3WBQKRI_cjs.isArray(base)) {
|
|
199
199
|
for (const b of base) {
|
|
200
|
-
if (singleUrl.startsWith(
|
|
200
|
+
if (singleUrl.startsWith(chunkURDI3IMY_cjs.normalizePathname(b))) {
|
|
201
201
|
return getLevel(singleUrl);
|
|
202
202
|
}
|
|
203
203
|
}
|
|
204
|
-
} else if (
|
|
204
|
+
} else if (chunkF3WBQKRI_cjs.isNonEmptyString(base) && singleUrl.startsWith(chunkURDI3IMY_cjs.normalizePathname(base))) {
|
|
205
205
|
return getLevel(singleUrl);
|
|
206
206
|
}
|
|
207
207
|
return null;
|
|
208
208
|
}
|
|
209
209
|
return getLevel(singleUrl);
|
|
210
210
|
}
|
|
211
|
-
if (
|
|
212
|
-
const result = url.map(processUrl).filter((r) => !
|
|
211
|
+
if (chunkF3WBQKRI_cjs.isArray(url)) {
|
|
212
|
+
const result = url.map(processUrl).filter((r) => !chunkF3WBQKRI_cjs.isNull(r));
|
|
213
213
|
const uniqueResult = removeDuplicates ? [...new Set(result)] : result;
|
|
214
214
|
if (uniqueResult.length === 1) {
|
|
215
215
|
return uniqueResult[0];
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
* ====================================================
|
|
3
3
|
* Rzl Utils-JS.
|
|
4
4
|
* ----------------------------------------------------
|
|
5
|
-
* Version: 3.5.
|
|
5
|
+
* Version: 3.5.5.
|
|
6
6
|
* Author: Rizalvin Dwiky.
|
|
7
7
|
* Repository: https://github.com/rzl-zone/utils-js.
|
|
8
8
|
* ====================================================
|
|
9
9
|
*/
|
|
10
|
-
import { isNonEmptyString } from './chunk-
|
|
10
|
+
import { isNonEmptyString } from './chunk-3KTD3QDI.js';
|
|
11
11
|
|
|
12
12
|
var isEmptyString = (value, options = {}) => {
|
|
13
13
|
return !isNonEmptyString(value, options);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* ====================================================
|
|
3
3
|
* Rzl Utils-JS.
|
|
4
4
|
* ----------------------------------------------------
|
|
5
|
-
* Version: 3.5.
|
|
5
|
+
* Version: 3.5.5.
|
|
6
6
|
* Author: Rizalvin Dwiky.
|
|
7
7
|
* Repository: https://github.com/rzl-zone/utils-js.
|
|
8
8
|
* ====================================================
|
|
@@ -10,11 +10,11 @@
|
|
|
10
10
|
'use strict';
|
|
11
11
|
|
|
12
12
|
var chunkDVMHRLKP_cjs = require('./chunk-DVMHRLKP.cjs');
|
|
13
|
-
var
|
|
14
|
-
var
|
|
13
|
+
var chunkYC7AK3KX_cjs = require('./chunk-YC7AK3KX.cjs');
|
|
14
|
+
var chunkF3WBQKRI_cjs = require('./chunk-F3WBQKRI.cjs');
|
|
15
15
|
|
|
16
16
|
function getRandomItem(array) {
|
|
17
|
-
if (!
|
|
17
|
+
if (!chunkF3WBQKRI_cjs.isNonEmptyArray(array)) return void 0;
|
|
18
18
|
const randomIndex = Math.floor(Math.random() * (array.length || 0));
|
|
19
19
|
return array[randomIndex];
|
|
20
20
|
}
|
|
@@ -25,11 +25,11 @@ var randomInt = (min, max) => {
|
|
|
25
25
|
`First parameter (\`min\`) and second parameter (\`max\`) must be of type \`integer-number\`${minValueNote(
|
|
26
26
|
min,
|
|
27
27
|
max
|
|
28
|
-
)}value, but received: ['min': \`${
|
|
28
|
+
)}value, but received: ['min': \`${chunkF3WBQKRI_cjs.getPreciseType(
|
|
29
29
|
min
|
|
30
|
-
)}\` - (with value: \`${
|
|
30
|
+
)}\` - (with value: \`${chunkYC7AK3KX_cjs.safeStableStringify(min)})\`, 'max': \`${chunkF3WBQKRI_cjs.getPreciseType(
|
|
31
31
|
max
|
|
32
|
-
)}\` - (with value: \`${
|
|
32
|
+
)}\` - (with value: \`${chunkYC7AK3KX_cjs.safeStableStringify(max)}\`)].`
|
|
33
33
|
);
|
|
34
34
|
}
|
|
35
35
|
if (min > max) {
|
|
@@ -44,31 +44,31 @@ var randomInt = (min, max) => {
|
|
|
44
44
|
return Math.floor(Math.random() * (max - min + 1)) + min;
|
|
45
45
|
};
|
|
46
46
|
var formatValue = (value) => {
|
|
47
|
-
return
|
|
47
|
+
return chunkF3WBQKRI_cjs.isNumber(value, { includeNaN: true }) ? value === Number.MIN_VALUE ? "`Number.MIN_VALUE`" : `${value}` : `\`${chunkF3WBQKRI_cjs.getPreciseType(value)}\``;
|
|
48
48
|
};
|
|
49
49
|
var minValueNote = (...values) => {
|
|
50
|
-
return values.some((v) =>
|
|
50
|
+
return values.some((v) => chunkF3WBQKRI_cjs.isNumber(v, { includeNaN: true }) && v === Number.MIN_VALUE) ? " and can't be `Number.MIN_VALUE` " : " ";
|
|
51
51
|
};
|
|
52
52
|
|
|
53
53
|
var randomIntByLength = (options) => {
|
|
54
|
-
if (!
|
|
54
|
+
if (!chunkF3WBQKRI_cjs.isPlainObject(options)) {
|
|
55
55
|
options = {};
|
|
56
56
|
}
|
|
57
57
|
const { minLength = 1, maxLength = 16, avoidZero = false } = options;
|
|
58
|
-
|
|
58
|
+
chunkF3WBQKRI_cjs.assertIsBoolean(avoidZero, {
|
|
59
59
|
message({ currentType, validType }) {
|
|
60
60
|
return `Parameters \`avoidZero\` must be of type \`${validType}\`, but received: \`${currentType}\`.`;
|
|
61
61
|
}
|
|
62
62
|
});
|
|
63
63
|
if (!chunkDVMHRLKP_cjs.isInteger(minLength) || !chunkDVMHRLKP_cjs.isInteger(maxLength)) {
|
|
64
64
|
throw new TypeError(
|
|
65
|
-
`Parameters \`minLength\` and \`maxLength\` must be of type \`integer-number\`, but received: ['minLength': \`${
|
|
65
|
+
`Parameters \`minLength\` and \`maxLength\` must be of type \`integer-number\`, but received: ['minLength': \`${chunkF3WBQKRI_cjs.getPreciseType(
|
|
66
66
|
minLength
|
|
67
|
-
)}\` - (with value: ${
|
|
67
|
+
)}\` - (with value: ${chunkYC7AK3KX_cjs.safeStableStringify(
|
|
68
68
|
minLength
|
|
69
|
-
)}), 'maxLength': \`${
|
|
69
|
+
)}), 'maxLength': \`${chunkF3WBQKRI_cjs.getPreciseType(
|
|
70
70
|
maxLength
|
|
71
|
-
)}\` - (with value: ${
|
|
71
|
+
)}\` - (with value: ${chunkYC7AK3KX_cjs.safeStableStringify(maxLength)})].`
|
|
72
72
|
);
|
|
73
73
|
}
|
|
74
74
|
if (minLength < 1 || maxLength > 16 || minLength > maxLength) {
|
|
@@ -87,7 +87,7 @@ var randomIntByLength = (options) => {
|
|
|
87
87
|
};
|
|
88
88
|
|
|
89
89
|
var randomStr = (options) => {
|
|
90
|
-
if (!
|
|
90
|
+
if (!chunkF3WBQKRI_cjs.isPlainObject(options)) {
|
|
91
91
|
options = {};
|
|
92
92
|
}
|
|
93
93
|
const {
|
|
@@ -96,20 +96,20 @@ var randomStr = (options) => {
|
|
|
96
96
|
type = "string",
|
|
97
97
|
avoidWhiteSpace = true
|
|
98
98
|
} = options;
|
|
99
|
-
|
|
99
|
+
chunkF3WBQKRI_cjs.assertIsBoolean(avoidWhiteSpace, {
|
|
100
100
|
message({ currentType, validType }) {
|
|
101
101
|
return `Parameters \`avoidWhiteSpace\` property of the \`options\` (first-parameter) must be of type \`${validType}\`, but received: \`${currentType}\`.`;
|
|
102
102
|
}
|
|
103
103
|
});
|
|
104
104
|
if (!chunkDVMHRLKP_cjs.isInteger(minLength) || !chunkDVMHRLKP_cjs.isInteger(maxLength)) {
|
|
105
105
|
throw new TypeError(
|
|
106
|
-
`Parameters \`minLength\` and \`maxLength\` must be of type \`integer-number\`, but received: ['minLength': \`${
|
|
106
|
+
`Parameters \`minLength\` and \`maxLength\` must be of type \`integer-number\`, but received: ['minLength': \`${chunkF3WBQKRI_cjs.getPreciseType(
|
|
107
107
|
minLength
|
|
108
|
-
)}\` - (with value: ${
|
|
108
|
+
)}\` - (with value: ${chunkYC7AK3KX_cjs.safeStableStringify(
|
|
109
109
|
minLength
|
|
110
|
-
)}), 'maxLength': \`${
|
|
110
|
+
)}), 'maxLength': \`${chunkF3WBQKRI_cjs.getPreciseType(
|
|
111
111
|
maxLength
|
|
112
|
-
)}\` - (with value: ${
|
|
112
|
+
)}\` - (with value: ${chunkYC7AK3KX_cjs.safeStableStringify(maxLength)})].`
|
|
113
113
|
);
|
|
114
114
|
}
|
|
115
115
|
if (minLength < 1 || maxLength > 5e3 || minLength > maxLength) {
|
|
@@ -119,9 +119,9 @@ var randomStr = (options) => {
|
|
|
119
119
|
}
|
|
120
120
|
if (type !== "string" && type !== "number") {
|
|
121
121
|
throw new TypeError(
|
|
122
|
-
`Parameter \`type\` must be of type \`string\` with value one of "string" | "number", but received: \`${
|
|
122
|
+
`Parameter \`type\` must be of type \`string\` with value one of "string" | "number", but received: \`${chunkF3WBQKRI_cjs.getPreciseType(
|
|
123
123
|
type
|
|
124
|
-
)}\`, with value: ${
|
|
124
|
+
)}\`, with value: ${chunkYC7AK3KX_cjs.safeStableStringify(type)}.`
|
|
125
125
|
);
|
|
126
126
|
}
|
|
127
127
|
const length = randomInt(minLength, maxLength);
|
|
@@ -130,7 +130,7 @@ var randomStr = (options) => {
|
|
|
130
130
|
};
|
|
131
131
|
const defaultNumberSet = "0123456789";
|
|
132
132
|
const defaultStringSet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
133
|
-
const baseCharSet = type === "number" ? (!
|
|
133
|
+
const baseCharSet = type === "number" ? (!chunkF3WBQKRI_cjs.isNaN(Number(options.replaceGenInt)) ? options.replaceGenInt : void 0) ?? defaultNumberSet : (options.replaceGenStr ? options.replaceGenStr : void 0) ?? defaultStringSet;
|
|
134
134
|
const characterSet = cleanCharacters(baseCharSet) + (options.addChar || "");
|
|
135
135
|
if (!characterSet.length) {
|
|
136
136
|
const errCharSet = () => {
|
|
@@ -2,18 +2,18 @@
|
|
|
2
2
|
* ====================================================
|
|
3
3
|
* Rzl Utils-JS.
|
|
4
4
|
* ----------------------------------------------------
|
|
5
|
-
* Version: 3.5.
|
|
5
|
+
* Version: 3.5.5.
|
|
6
6
|
* Author: Rizalvin Dwiky.
|
|
7
7
|
* Repository: https://github.com/rzl-zone/utils-js.
|
|
8
8
|
* ====================================================
|
|
9
9
|
*/
|
|
10
10
|
'use strict';
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var chunkF3WBQKRI_cjs = require('./chunk-F3WBQKRI.cjs');
|
|
13
13
|
|
|
14
14
|
var assertIsString = (value, options = {}) => {
|
|
15
|
-
if (
|
|
16
|
-
const errorMessage =
|
|
15
|
+
if (chunkF3WBQKRI_cjs.isString(value)) return;
|
|
16
|
+
const errorMessage = chunkF3WBQKRI_cjs.resolveErrorMessageAssertions({
|
|
17
17
|
value,
|
|
18
18
|
options,
|
|
19
19
|
requiredValidType: "string"
|
package/dist/chunk-KHO2SBNA.cjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* ====================================================
|
|
3
3
|
* Rzl Utils-JS.
|
|
4
4
|
* ----------------------------------------------------
|
|
5
|
-
* Version: 3.5.
|
|
5
|
+
* Version: 3.5.5.
|
|
6
6
|
* Author: Rizalvin Dwiky.
|
|
7
7
|
* Repository: https://github.com/rzl-zone/utils-js.
|
|
8
8
|
* ====================================================
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
* ====================================================
|
|
3
3
|
* Rzl Utils-JS.
|
|
4
4
|
* ----------------------------------------------------
|
|
5
|
-
* Version: 3.5.
|
|
5
|
+
* Version: 3.5.5.
|
|
6
6
|
* Author: Rizalvin Dwiky.
|
|
7
7
|
* Repository: https://github.com/rzl-zone/utils-js.
|
|
8
8
|
* ====================================================
|
|
9
9
|
*/
|
|
10
|
-
import { isNonEmptyString } from './chunk-
|
|
10
|
+
import { isNonEmptyString } from './chunk-3KTD3QDI.js';
|
|
11
11
|
|
|
12
12
|
var KNOWN_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
13
13
|
// 📄 Text & Document
|