@rzl-zone/utils-js 3.3.1 → 3.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +94 -45
- package/dist/assertions/index.cjs +34 -1
- package/dist/assertions/index.d.ts +2 -2
- package/dist/assertions/index.js +5 -1
- package/dist/chunk-2CQX5CBG.js +247 -1
- package/dist/chunk-2IOOEY45.cjs +20 -1
- package/dist/chunk-2WA36TC5.cjs +176 -0
- package/dist/chunk-3IBQ5MOM.js +6 -1
- package/dist/chunk-3VA554KW.js +23 -1
- package/dist/chunk-5757UBXJ.cjs +144 -1
- package/dist/chunk-5IGC6PBH.js +22 -1
- package/dist/chunk-5KJFVIQT.cjs +55 -1
- package/dist/chunk-6JFCSH7J.js +24 -1
- package/dist/chunk-6JFZL7YE.cjs +14 -1
- package/dist/chunk-7ODAAXX5.cjs +361 -1
- package/dist/chunk-BAV5T2E3.cjs +5 -1
- package/dist/chunk-CAH33WOQ.cjs +25 -1
- package/dist/chunk-CDCERIZ2.js +164 -0
- package/dist/chunk-CKTLUNWX.js +12 -1
- package/dist/chunk-CMW2TBOQ.js +522 -1
- package/dist/chunk-D3ENH7H6.cjs +87 -1
- package/dist/chunk-DEZZUYE2.js +139 -1
- package/dist/chunk-DVMHRLKP.cjs +6 -1
- package/dist/chunk-DWF2R5GD.cjs +212 -1
- package/dist/chunk-E55EQK2U.cjs +8 -1
- package/dist/chunk-E74U6CYP.cjs +8 -1
- package/dist/chunk-EL6A35UR.cjs +51 -1
- package/dist/chunk-F6IPNNSJ.cjs +531 -1
- package/dist/chunk-FJZGG54N.cjs +252 -1
- package/dist/chunk-FWCKOJZM.js +519 -1
- package/dist/chunk-FWHNWL2P.cjs +409 -1
- package/dist/chunk-GGEADHZO.js +78 -1
- package/dist/chunk-GQR4R5WY.js +21 -1
- package/dist/chunk-H66AC7GK.cjs +81 -1
- package/dist/chunk-HQWOFR56.cjs +23 -1
- package/dist/chunk-HYRQMTRH.cjs +14 -1
- package/dist/chunk-IRFL4MAX.js +53 -1
- package/dist/chunk-IVL7CKVH.cjs +26 -1
- package/dist/chunk-IZPBKKPO.js +6 -1
- package/dist/chunk-JBQMXC5I.cjs +93 -1
- package/dist/chunk-JEQEF5WD.js +81 -1
- package/dist/chunk-JMJQCN74.js +334 -1
- package/dist/chunk-KHO2SBNA.cjs +6 -1
- package/dist/chunk-KVAL5PAG.cjs +16 -1
- package/dist/chunk-L5RDAVVH.js +5 -1
- package/dist/chunk-LS6U7FAY.cjs +98 -1
- package/dist/chunk-NBZWMBO6.js +88 -1
- package/dist/chunk-NRF6LWBC.cjs +45 -1
- package/dist/chunk-OI5XKNZO.js +42 -1
- package/dist/chunk-ONZFBJVW.js +5 -1
- package/dist/chunk-OYTYSY7G.js +94 -1
- package/dist/chunk-PET42Z7W.js +107 -1
- package/dist/chunk-PZQ6I4JJ.cjs +559 -1
- package/dist/chunk-QBKAEVYG.js +102 -1
- package/dist/chunk-QNKGP5DY.js +5 -1
- package/dist/chunk-RIPKY4RU.js +407 -1
- package/dist/chunk-RZW35UN5.cjs +105 -1
- package/dist/chunk-SBFNXGTJ.js +207 -1
- package/dist/chunk-SBKGWRS5.js +12 -1
- package/dist/chunk-SIM77PU4.js +46 -1
- package/dist/chunk-T2T7K3KR.js +18 -1
- package/dist/chunk-T7PU2V7X.cjs +111 -1
- package/dist/chunk-UDA26MCU.cjs +6 -1
- package/dist/chunk-V45XJKHW.cjs +8 -1
- package/dist/chunk-VJDDGRIK.cjs +6 -1
- package/dist/chunk-W2WNBUDE.js +6 -1
- package/dist/chunk-WVSPXFTY.js +5 -1
- package/dist/chunk-XABCB3Y7.cjs +563 -1
- package/dist/chunk-XEDXFSGI.js +14 -1
- package/dist/chunk-YKPSRP5G.js +552 -1
- package/dist/chunk-YWHHVDT4.js +4 -1
- package/dist/chunk-ZETAZZLD.cjs +27 -1
- package/dist/conversions/index.cjs +97 -1
- package/dist/conversions/index.d.ts +2 -2
- package/dist/conversions/index.js +16 -1
- package/dist/events/index.cjs +25 -1
- package/dist/events/index.d.ts +1 -1
- package/dist/events/index.js +4 -1
- package/dist/formatters/index.cjs +55 -1
- package/dist/formatters/index.d.ts +2 -2
- package/dist/formatters/index.js +10 -1
- package/dist/generators/index.cjs +31 -1
- package/dist/generators/index.d.ts +2 -2
- package/dist/generators/index.js +6 -1
- package/dist/index.d.ts +1 -1
- package/dist/{isPlainObject-DGJkcFYw.d.ts → isPlainObject-FWmcJF6k.d.ts} +5 -5
- package/dist/next/index.cjs +205 -1
- package/dist/next/index.d.ts +2 -2
- package/dist/next/index.js +200 -1
- package/dist/next/server/index.cjs +34 -1
- package/dist/next/server/index.d.ts +1 -1
- package/dist/next/server/index.js +32 -1
- package/dist/operations/index.cjs +26 -1
- package/dist/operations/index.d.ts +2 -2
- package/dist/operations/index.js +9 -1
- package/dist/parsers/index.cjs +11 -1
- package/dist/parsers/index.d.ts +1 -1
- package/dist/parsers/index.js +2 -1
- package/dist/predicates/index.cjs +292 -1
- package/dist/predicates/index.d.ts +4 -4
- package/dist/predicates/index.js +15 -1
- package/dist/promises/index.cjs +18 -1
- package/dist/promises/index.d.ts +2 -2
- package/dist/promises/index.js +5 -1
- package/dist/rzl-utils.global.js +16 -1
- package/dist/strings/index.cjs +75 -1
- package/dist/strings/index.d.ts +2 -2
- package/dist/strings/index.js +6 -1
- package/dist/tailwind/index.cjs +36 -1
- package/dist/tailwind/index.d.ts +1 -1
- package/dist/tailwind/index.js +3 -1
- package/dist/urls/index.cjs +44 -1
- package/dist/urls/index.d.ts +1 -1
- package/dist/urls/index.js +15 -1
- package/package.json +16 -24
- package/dist/NumberRangeUnion-B6bhM2s7.d.ts +0 -33
- package/dist/any-v4TsK9ES.d.ts +0 -66
- package/dist/arrays-normalize-recursive-BqmVuFlD.d.ts +0 -72
- package/dist/chunk-JYQTCICM.js +0 -1
- package/dist/chunk-YLA3DURS.cjs +0 -1
- package/dist/extends-DtdRjDyU.d.ts +0 -343
- package/dist/if-ChM35c_q.d.ts +0 -19
- package/dist/is-array-BJeHxPM3.d.ts +0 -952
- package/dist/never-D89PbPh5.d.ts +0 -66
- package/dist/nils-CO8zLHSB.d.ts +0 -151
- package/dist/or-C6qzKt2I.d.ts +0 -82
- package/dist/override-CL2olHE5.d.ts +0 -59
- package/dist/pick-BSMX6Xe2.d.ts +0 -15
- package/dist/prettify-3o8_Kw6b.d.ts +0 -564
- package/dist/promises-LU7K00H0.d.ts +0 -72
- package/dist/string-B1jlOnws.d.ts +0 -312
- package/dist/types/index.d.ts +0 -3345
package/dist/chunk-SBFNXGTJ.js
CHANGED
|
@@ -1 +1,207 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { isURL } from './chunk-ONZFBJVW.js';
|
|
2
|
+
import { normalizeString } from './chunk-IZPBKKPO.js';
|
|
3
|
+
import { toStringArrayUnRecursive } from './chunk-OI5XKNZO.js';
|
|
4
|
+
import { isEmptyValue } from './chunk-GQR4R5WY.js';
|
|
5
|
+
import { isInteger } from './chunk-WVSPXFTY.js';
|
|
6
|
+
import { normalizePathname } from './chunk-GGEADHZO.js';
|
|
7
|
+
import { isEmptyString } from './chunk-W2WNBUDE.js';
|
|
8
|
+
import { assertIsArray } from './chunk-CKTLUNWX.js';
|
|
9
|
+
import { safeStableStringify } from './chunk-PET42Z7W.js';
|
|
10
|
+
import { isString, getPreciseType, isUndefined, isNonEmptyString, isFunction, isNumber, isError, isArray, isNil, isNull, isPlainObject, isBoolean, isNonEmptyArray } from './chunk-CMW2TBOQ.js';
|
|
11
|
+
var constructURL = (baseUrl, queryParams, removeParams) => {
|
|
12
|
+
if (isString(baseUrl)) {
|
|
13
|
+
if (isEmptyString(baseUrl)) {
|
|
14
|
+
throw new TypeError(`First parameter (\`baseUrl\`) cannot be an empty-string.`);
|
|
15
|
+
}
|
|
16
|
+
baseUrl = normalizeString(baseUrl);
|
|
17
|
+
} else if (!isURL(baseUrl)) {
|
|
18
|
+
throw new TypeError(
|
|
19
|
+
`First parameter (\`baseUrl\`) must be of type an URL instance or a \`string\` and a non empty-string, but received: \`${getPreciseType(
|
|
20
|
+
baseUrl
|
|
21
|
+
)}\`, with current value: \`${safeStableStringify(baseUrl)}\`.`
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
if (!isUndefined(removeParams)) {
|
|
25
|
+
assertIsArray(removeParams, {
|
|
26
|
+
message: ({ currentType, validType }) => `Third parameter (\`removeParams\`) must be of type \`${validType} of strings\`, but received: \`${currentType}\`.`
|
|
27
|
+
});
|
|
28
|
+
if (!removeParams.every((param) => isNonEmptyString(param))) {
|
|
29
|
+
throw new TypeError(
|
|
30
|
+
`Third parameter (\`removeParams\`) must be of type \`array\` and contains \`string\` only and non empty-string.`
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
try {
|
|
35
|
+
if (!isUndefined(queryParams) && !isFunction(queryParams[Symbol.iterator])) {
|
|
36
|
+
throw new TypeError(
|
|
37
|
+
`Second parameter (\`queryParams\`) must be iterable (like URLSearchParams.entries() or an array of [[string, string | number]...]), but received: \`${getPreciseType(
|
|
38
|
+
queryParams
|
|
39
|
+
)}\`, with value: \`${safeStableStringify(queryParams)}\`.`
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
const urlInstance = new URL(baseUrl);
|
|
43
|
+
if (!isUndefined(queryParams)) {
|
|
44
|
+
const paramObject = Object.fromEntries(queryParams);
|
|
45
|
+
if (!isEmptyValue(paramObject)) {
|
|
46
|
+
const mergedParams = new URLSearchParams(urlInstance.search);
|
|
47
|
+
for (const [key, value] of Object.entries(paramObject)) {
|
|
48
|
+
if (!isNonEmptyString(value) && !isNumber(value, { includeNaN: true })) {
|
|
49
|
+
throw new TypeError(
|
|
50
|
+
`Second parameter (\`queryParams\`) must be iterable (like URLSearchParams.entries() or an array of [[string, string | number]...]), but received: \`${getPreciseType(
|
|
51
|
+
queryParams
|
|
52
|
+
)}\`, with value: \`${safeStableStringify(queryParams)}\`.`
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
mergedParams.set(key, String(value));
|
|
56
|
+
}
|
|
57
|
+
if (removeParams?.length) {
|
|
58
|
+
toStringArrayUnRecursive(removeParams).map((paramKey) => {
|
|
59
|
+
mergedParams.delete(paramKey);
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
urlInstance.search = mergedParams.toString();
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
removeParams?.forEach((param) => urlInstance.searchParams.delete(param));
|
|
66
|
+
return urlInstance;
|
|
67
|
+
} catch (error) {
|
|
68
|
+
if (isError(error)) throw error;
|
|
69
|
+
throw new Error(
|
|
70
|
+
"Failed to construct a valid URL in `constructURL()`, Error:" + error
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
var extractURLs = (url) => {
|
|
75
|
+
if (!isNonEmptyString(url)) return null;
|
|
76
|
+
let decoded;
|
|
77
|
+
try {
|
|
78
|
+
decoded = decodeURIComponent(url);
|
|
79
|
+
} catch {
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
const urlPattern = /https?:\/\/.*?(?=https?:\/\/|\s|$)/g;
|
|
83
|
+
const matches = decoded.match(urlPattern);
|
|
84
|
+
if (!matches) return null;
|
|
85
|
+
const cleaned = matches.map((url2) => url2.replace(/[.,;:!?)]*$/, "")).filter((url2) => {
|
|
86
|
+
try {
|
|
87
|
+
const u = new URL(url2);
|
|
88
|
+
return u.protocol === "http:" || u.protocol === "https:";
|
|
89
|
+
} catch {
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
return cleaned.length ? cleaned : null;
|
|
94
|
+
};
|
|
95
|
+
var getFirstPrefixPathname = (result, defaultValue = "/") => {
|
|
96
|
+
if (!isNonEmptyString(defaultValue)) {
|
|
97
|
+
throw new TypeError(
|
|
98
|
+
`Second parameter (\`defaultValue\`) must be of type \`string\` and not an \`empty-string\`, but received: \`${getPreciseType(
|
|
99
|
+
defaultValue
|
|
100
|
+
)}\`, with value: \`${safeStableStringify(defaultValue)}\`.`
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
if (isArray(result)) {
|
|
104
|
+
if (!result.every((item) => isString(item))) {
|
|
105
|
+
throw new TypeError(
|
|
106
|
+
`First parameter (\`result\`) must be of type \`string\` or \`array of string\`, but received: \`${getPreciseType(
|
|
107
|
+
result
|
|
108
|
+
)}\`, with value: \`${safeStableStringify(result)}\`.`
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
for (const item of result) {
|
|
112
|
+
const normalized = normalizePathname(item);
|
|
113
|
+
if (normalized !== "/") {
|
|
114
|
+
return normalized;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return normalizePathname(defaultValue);
|
|
118
|
+
}
|
|
119
|
+
if (isString(result)) {
|
|
120
|
+
const normalized = normalizePathname(result);
|
|
121
|
+
return normalized !== "/" ? normalized : normalizePathname(defaultValue);
|
|
122
|
+
}
|
|
123
|
+
if (!isNil(result)) {
|
|
124
|
+
throw new TypeError(
|
|
125
|
+
`First parameter (\`result\`) must be of type \`string\`, \`array-string\`, \`null\` or \`undefined\`, but received: \`${getPreciseType(
|
|
126
|
+
result
|
|
127
|
+
)}\`.`
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
return normalizePathname(defaultValue);
|
|
131
|
+
};
|
|
132
|
+
var getPrefixPathname = (url, base = null, options = {}) => {
|
|
133
|
+
const errors = [];
|
|
134
|
+
if (!isString(url) && !isArray(url)) {
|
|
135
|
+
errors.push(
|
|
136
|
+
`First parameter (\`url\`) must be of type \`string\` or \`array-string\`, but received: \`${getPreciseType(
|
|
137
|
+
url
|
|
138
|
+
)}\`.`
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
if (!isString(base) && !isArray(base) && !isNull(base)) {
|
|
142
|
+
errors.push(
|
|
143
|
+
`Second parameter (\`base\`) must be of type \`string\`, \`array-string\` or \`null\`, but received: \`${getPreciseType(
|
|
144
|
+
base
|
|
145
|
+
)}\`.`
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
if (!isPlainObject(options)) {
|
|
149
|
+
errors.push(
|
|
150
|
+
`Second parameter (\`options\`) must be of type \`plain-object\`, but received: \`${getPreciseType(
|
|
151
|
+
options
|
|
152
|
+
)}\`.`
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
const { levels = 1, removeDuplicates = true } = options;
|
|
156
|
+
if (!isInteger(levels) || isInteger(levels) && levels < 0) {
|
|
157
|
+
errors.push(
|
|
158
|
+
`Parameter \`levels\` property of the \`options\` (second parameter) must be of type \`integer-number\` and minimum is \`0\`, but received: \`${getPreciseType(
|
|
159
|
+
levels
|
|
160
|
+
)}\`, with value: \`${safeStableStringify(levels)}\`.`
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
if (!isBoolean(removeDuplicates)) {
|
|
164
|
+
errors.push(
|
|
165
|
+
`Parameter \`removeDuplicates\` property of the \`options\` (second parameter) must be of type \`boolean\`, but received: \`${getPreciseType(
|
|
166
|
+
removeDuplicates
|
|
167
|
+
)}\`.`
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
if (isNonEmptyArray(errors)) {
|
|
171
|
+
throw new TypeError(
|
|
172
|
+
`Invalid parameter(s) in \`getPrefixPathname\` function:
|
|
173
|
+
- ${errors.join("\n- ")}`
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
function getLevel(singleUrl) {
|
|
177
|
+
const parts = normalizePathname(singleUrl).split("/").filter(Boolean);
|
|
178
|
+
return `/${parts.slice(0, levels).join("/")}`;
|
|
179
|
+
}
|
|
180
|
+
function processUrl(singleUrl) {
|
|
181
|
+
if (base) {
|
|
182
|
+
singleUrl = normalizePathname(singleUrl);
|
|
183
|
+
if (isArray(base)) {
|
|
184
|
+
for (const b of base) {
|
|
185
|
+
if (singleUrl.startsWith(normalizePathname(b))) {
|
|
186
|
+
return getLevel(singleUrl);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
} else if (isNonEmptyString(base) && singleUrl.startsWith(normalizePathname(base))) {
|
|
190
|
+
return getLevel(singleUrl);
|
|
191
|
+
}
|
|
192
|
+
return null;
|
|
193
|
+
}
|
|
194
|
+
return getLevel(singleUrl);
|
|
195
|
+
}
|
|
196
|
+
if (isArray(url)) {
|
|
197
|
+
const result = url.map(processUrl).filter((r) => !isNull(r));
|
|
198
|
+
const uniqueResult = removeDuplicates ? [...new Set(result)] : result;
|
|
199
|
+
if (uniqueResult.length === 1) {
|
|
200
|
+
return uniqueResult[0];
|
|
201
|
+
}
|
|
202
|
+
return uniqueResult;
|
|
203
|
+
}
|
|
204
|
+
return processUrl(url);
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
export { constructURL, extractURLs, getFirstPrefixPathname, getPrefixPathname };
|
package/dist/chunk-SBKGWRS5.js
CHANGED
|
@@ -1 +1,12 @@
|
|
|
1
|
-
import{isString
|
|
1
|
+
import { isString, resolveErrorMessageAssertions } from './chunk-CMW2TBOQ.js';
|
|
2
|
+
var assertIsString = (value, options = {}) => {
|
|
3
|
+
if (isString(value)) return;
|
|
4
|
+
const errorMessage = resolveErrorMessageAssertions({
|
|
5
|
+
value,
|
|
6
|
+
options,
|
|
7
|
+
requiredValidType: "string"
|
|
8
|
+
});
|
|
9
|
+
throw new TypeError(errorMessage);
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export { assertIsString };
|
package/dist/chunk-SIM77PU4.js
CHANGED
|
@@ -1 +1,46 @@
|
|
|
1
|
-
import{isServer
|
|
1
|
+
import { isServer } from './chunk-L5RDAVVH.js';
|
|
2
|
+
import { assertIsString } from './chunk-SBKGWRS5.js';
|
|
3
|
+
import { isPlainObject, hasOwnProp, isNonEmptyString, isNumber } from './chunk-CMW2TBOQ.js';
|
|
4
|
+
var disableUserInteraction = (className = "on_processing") => {
|
|
5
|
+
if (isServer()) return;
|
|
6
|
+
assertIsString(className, {
|
|
7
|
+
message({ validType, currentType }) {
|
|
8
|
+
return `First parameter \`className\` must be of type \`${validType}\`, but received: \`${currentType}\`.`;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const { documentElement } = document;
|
|
12
|
+
if (documentElement && !documentElement.classList.contains(className)) {
|
|
13
|
+
documentElement.classList.add(className);
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
var enableUserInteraction = (className = "on_processing") => {
|
|
17
|
+
if (isServer()) return;
|
|
18
|
+
assertIsString(className, {
|
|
19
|
+
message({ validType, currentType }) {
|
|
20
|
+
return `First parameter \`className\` must be of type \`${validType}\`, but received: \`${currentType}\`.`;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
const { documentElement } = document;
|
|
24
|
+
if (documentElement && documentElement.classList.contains(className)) {
|
|
25
|
+
documentElement.classList.remove(className);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
var removeElementFocus = () => {
|
|
29
|
+
if (isServer()) return;
|
|
30
|
+
const activeElement = document.activeElement;
|
|
31
|
+
if (activeElement instanceof HTMLElement) {
|
|
32
|
+
activeElement.blur();
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
var scrollToTop = (options) => {
|
|
36
|
+
if (isServer()) return;
|
|
37
|
+
if (!isPlainObject(options)) {
|
|
38
|
+
options = {};
|
|
39
|
+
}
|
|
40
|
+
const behavior = hasOwnProp(options, "behavior") && isNonEmptyString(options.behavior) && ["auto", "instant", "smooth"].includes(options.behavior) ? options.behavior : "smooth";
|
|
41
|
+
let timeout = hasOwnProp(options, "timeout") && isNumber(options.timeout) && options.timeout >= 1 ? options.timeout : 1;
|
|
42
|
+
timeout = timeout > 2147483647 ? 2147483647 : timeout;
|
|
43
|
+
setTimeout(() => window.scrollTo({ top: 0, left: 0, behavior }), timeout);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export { disableUserInteraction, enableUserInteraction, removeElementFocus, scrollToTop };
|
package/dist/chunk-T2T7K3KR.js
CHANGED
|
@@ -1 +1,18 @@
|
|
|
1
|
-
import{isNonEmptyString
|
|
1
|
+
import { isNonEmptyString, isPlainObject } from './chunk-CMW2TBOQ.js';
|
|
2
|
+
var normalizeSpaces = (value, options = {
|
|
3
|
+
withTrim: true,
|
|
4
|
+
trimOnly: false
|
|
5
|
+
}) => {
|
|
6
|
+
if (!isNonEmptyString(value)) return "";
|
|
7
|
+
if (!isPlainObject(options)) {
|
|
8
|
+
options = {};
|
|
9
|
+
}
|
|
10
|
+
const { trimOnly = false, withTrim = true } = options;
|
|
11
|
+
if (trimOnly) return value.trim();
|
|
12
|
+
if (withTrim) {
|
|
13
|
+
value = value.trim();
|
|
14
|
+
}
|
|
15
|
+
return value.replace(/\s+/g, " ");
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export { normalizeSpaces };
|
package/dist/chunk-T7PU2V7X.cjs
CHANGED
|
@@ -1 +1,111 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkUDA26MCU_cjs = require('./chunk-UDA26MCU.cjs');
|
|
4
|
+
var chunkPZQ6I4JJ_cjs = require('./chunk-PZQ6I4JJ.cjs');
|
|
5
|
+
function isMap(value) {
|
|
6
|
+
return Object.prototype.toString.call(value) === "[object Map]" || value instanceof Map;
|
|
7
|
+
}
|
|
8
|
+
var isDate = (value, options = {}) => {
|
|
9
|
+
chunkPZQ6I4JJ_cjs.assertIsPlainObject(options, {
|
|
10
|
+
message: ({ currentType, validType }) => `Second parameter (\`options\`) must be of type \`${validType}\`, but received: \`${currentType}\`.`
|
|
11
|
+
});
|
|
12
|
+
const skipInvalidDate = chunkPZQ6I4JJ_cjs.isPlainObject(options) && chunkPZQ6I4JJ_cjs.isBoolean(options.skipInvalidDate) ? options.skipInvalidDate : false;
|
|
13
|
+
const instanceDate = value instanceof Date;
|
|
14
|
+
if (skipInvalidDate) return instanceDate;
|
|
15
|
+
return instanceDate && !chunkPZQ6I4JJ_cjs.isNaN(value.getTime());
|
|
16
|
+
};
|
|
17
|
+
var safeStableStringify = (value, options = {}) => {
|
|
18
|
+
chunkPZQ6I4JJ_cjs.assertIsPlainObject(options, {
|
|
19
|
+
message: ({ currentType, validType }) => `Second parameter (\`options\`) must be of type \`${validType}\`, but received: \`${currentType}\`.`
|
|
20
|
+
});
|
|
21
|
+
const pretty = chunkPZQ6I4JJ_cjs.hasOwnProp(options, "pretty") ? options.pretty : false;
|
|
22
|
+
const sortKeys = chunkPZQ6I4JJ_cjs.hasOwnProp(options, "sortKeys") ? options.sortKeys : true;
|
|
23
|
+
const sortArray = chunkPZQ6I4JJ_cjs.hasOwnProp(options, "sortArray") ? options.sortArray : false;
|
|
24
|
+
const keepUndefined = chunkPZQ6I4JJ_cjs.hasOwnProp(options, "keepUndefined") ? options.keepUndefined : false;
|
|
25
|
+
if (!chunkPZQ6I4JJ_cjs.isBoolean(sortKeys) || !chunkPZQ6I4JJ_cjs.isBoolean(sortArray) || !chunkPZQ6I4JJ_cjs.isBoolean(pretty) || !chunkPZQ6I4JJ_cjs.isBoolean(keepUndefined)) {
|
|
26
|
+
throw new TypeError(
|
|
27
|
+
`Parameters \`sortKeys\`, \`sortArray\`, \`keepUndefined\` and \`pretty\` property of the \`options\` (second parameter) must be of type \`boolean\`, but received: "['sortKeys': \`${chunkPZQ6I4JJ_cjs.getPreciseType(
|
|
28
|
+
sortKeys
|
|
29
|
+
)}\`, 'sortArray': \`${chunkPZQ6I4JJ_cjs.getPreciseType(
|
|
30
|
+
sortArray
|
|
31
|
+
)}\`, 'keepUndefined': \`${chunkPZQ6I4JJ_cjs.getPreciseType(
|
|
32
|
+
keepUndefined
|
|
33
|
+
)}\`, 'pretty': \`${chunkPZQ6I4JJ_cjs.getPreciseType(pretty)}\`]".`
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
if (chunkPZQ6I4JJ_cjs.isUndefined(value)) {
|
|
37
|
+
return keepUndefined ? "undefined" : "null";
|
|
38
|
+
}
|
|
39
|
+
const seen = /* @__PURE__ */ new WeakSet();
|
|
40
|
+
const isPrimitive = (val) => chunkPZQ6I4JJ_cjs.isNull(val) || !chunkPZQ6I4JJ_cjs.isObjectOrArray(val) && !chunkPZQ6I4JJ_cjs.isFunction(val);
|
|
41
|
+
const deepProcess = (val) => {
|
|
42
|
+
if (chunkPZQ6I4JJ_cjs.isNumberObject(val)) {
|
|
43
|
+
const valOf = val.valueOf();
|
|
44
|
+
return chunkPZQ6I4JJ_cjs.isNaN(valOf) || chunkPZQ6I4JJ_cjs.isInfinityNumber(valOf) ? null : valOf;
|
|
45
|
+
}
|
|
46
|
+
if (chunkPZQ6I4JJ_cjs.isStringObject(val)) return val.valueOf();
|
|
47
|
+
if (chunkPZQ6I4JJ_cjs.isBooleanObject(val)) return val.valueOf();
|
|
48
|
+
if (chunkPZQ6I4JJ_cjs.isFunction(val) || chunkPZQ6I4JJ_cjs.isSymbol(val)) return void 0;
|
|
49
|
+
if (chunkUDA26MCU_cjs.isBigInt(val)) return val.toString();
|
|
50
|
+
if (chunkPZQ6I4JJ_cjs.isNaN(val) || chunkPZQ6I4JJ_cjs.isInfinityNumber(val)) return null;
|
|
51
|
+
if (chunkPZQ6I4JJ_cjs.isUndefined(val)) {
|
|
52
|
+
return keepUndefined ? void 0 : null;
|
|
53
|
+
}
|
|
54
|
+
if (chunkPZQ6I4JJ_cjs.isObjectOrArray(val)) {
|
|
55
|
+
if (seen.has(val)) return "[Circular]";
|
|
56
|
+
seen.add(val);
|
|
57
|
+
if (isDate(val)) return val.toISOString();
|
|
58
|
+
if (isMap(val)) {
|
|
59
|
+
return {
|
|
60
|
+
map: Array.from(val.entries()).map(([k, v]) => [k, deepProcess(v)])
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
if (chunkPZQ6I4JJ_cjs.isSet(val)) return { set: Array.from(val.values()).map(deepProcess) };
|
|
64
|
+
if (chunkPZQ6I4JJ_cjs.isArray(val)) {
|
|
65
|
+
const processedArr = val.map(deepProcess);
|
|
66
|
+
if (sortArray) {
|
|
67
|
+
const primitives = [];
|
|
68
|
+
const nonPrimitives = [];
|
|
69
|
+
for (const item of processedArr) {
|
|
70
|
+
if (isPrimitive(item)) primitives.push(item);
|
|
71
|
+
else nonPrimitives.push(item);
|
|
72
|
+
}
|
|
73
|
+
primitives.sort((a, b) => {
|
|
74
|
+
if (chunkPZQ6I4JJ_cjs.isNumber(a) && chunkPZQ6I4JJ_cjs.isNumber(b)) return a - b;
|
|
75
|
+
return String(a).localeCompare(String(b));
|
|
76
|
+
});
|
|
77
|
+
return [...primitives, ...nonPrimitives];
|
|
78
|
+
}
|
|
79
|
+
return processedArr;
|
|
80
|
+
}
|
|
81
|
+
const keys = Object.keys(val);
|
|
82
|
+
if (sortKeys) {
|
|
83
|
+
keys.sort((a, b) => {
|
|
84
|
+
const na = Number(a);
|
|
85
|
+
const nb = Number(b);
|
|
86
|
+
if (!chunkPZQ6I4JJ_cjs.isNaN(na) && !chunkPZQ6I4JJ_cjs.isNaN(nb)) return na - nb;
|
|
87
|
+
return a.localeCompare(b);
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
const result = {};
|
|
91
|
+
if (chunkPZQ6I4JJ_cjs.isObject(val)) {
|
|
92
|
+
for (const k of keys) {
|
|
93
|
+
const v = deepProcess(val[k]);
|
|
94
|
+
if (!chunkPZQ6I4JJ_cjs.isUndefined(v)) result[k] = v;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return result;
|
|
98
|
+
}
|
|
99
|
+
return val;
|
|
100
|
+
};
|
|
101
|
+
try {
|
|
102
|
+
return JSON.stringify(deepProcess(value), null, pretty ? 2 : 0);
|
|
103
|
+
} catch (err) {
|
|
104
|
+
console.warn("Error in safeStableStringify:", err);
|
|
105
|
+
return "{}";
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
exports.isDate = isDate;
|
|
110
|
+
exports.isMap = isMap;
|
|
111
|
+
exports.safeStableStringify = safeStableStringify;
|
package/dist/chunk-UDA26MCU.cjs
CHANGED
package/dist/chunk-V45XJKHW.cjs
CHANGED
|
@@ -1 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkPZQ6I4JJ_cjs = require('./chunk-PZQ6I4JJ.cjs');
|
|
4
|
+
function isFinite(value) {
|
|
5
|
+
return chunkPZQ6I4JJ_cjs.isNumber(value) && Number.isFinite(value);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
exports.isFinite = isFinite;
|
package/dist/chunk-VJDDGRIK.cjs
CHANGED
package/dist/chunk-W2WNBUDE.js
CHANGED
|
@@ -1 +1,6 @@
|
|
|
1
|
-
import{isNonEmptyString
|
|
1
|
+
import { isNonEmptyString } from './chunk-CMW2TBOQ.js';
|
|
2
|
+
var isEmptyString = (value, options = {}) => {
|
|
3
|
+
return !isNonEmptyString(value, options);
|
|
4
|
+
};
|
|
5
|
+
|
|
6
|
+
export { isEmptyString };
|
package/dist/chunk-WVSPXFTY.js
CHANGED