@rzl-zone/utils-js 3.5.7 → 3.7.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 +1 -1
- package/dist/assertions/index.cjs +1 -1
- package/dist/assertions/index.d.ts +1 -1
- package/dist/assertions/index.js +1 -1
- package/dist/chunk-2CQI36UD.cjs +1 -1
- package/dist/chunk-2VO2CBTU.js +1 -1
- package/dist/chunk-3KTD3QDI.js +1 -1
- package/dist/{chunk-RS5RBLPB.js → chunk-3LEWQV3R.js} +46 -8
- package/dist/chunk-4ACKNPL5.js +1 -1
- package/dist/chunk-4ZOXSUXB.js +1 -1
- package/dist/chunk-5NN4ZDE2.cjs +1 -1
- package/dist/chunk-66WLOZOD.cjs +1 -1
- package/dist/{chunk-6DSPJA5U.js → chunk-6PKW4WCT.js} +2 -2
- package/dist/chunk-6RFNZ2ZZ.cjs +1 -1
- package/dist/chunk-6WMB5AJR.js +1 -1
- package/dist/chunk-7QQV66RX.cjs +1 -1
- package/dist/chunk-7WBMA2VE.cjs +1 -1
- package/dist/chunk-7ZNEUWYP.js +1 -1
- package/dist/chunk-A3YI6Y2P.js +1 -1
- package/dist/chunk-ABA2ZSBQ.js +1 -1
- package/dist/chunk-AKKM6MOX.cjs +1 -1
- package/dist/chunk-ATLFMKAF.cjs +1 -1
- package/dist/chunk-B4SDEBN7.cjs +1 -1
- package/dist/chunk-B6UIKBHR.cjs +1 -1
- package/dist/chunk-BAV5T2E3.cjs +1 -1
- package/dist/chunk-BG3AS5BU.cjs +173 -0
- package/dist/chunk-BYUT376O.cjs +1 -1
- package/dist/{chunk-RIEYB2AW.cjs → chunk-CKUEZF4R.cjs} +1 -1
- package/dist/chunk-D53CE4BT.js +1 -1
- package/dist/chunk-DPLL67OT.js +1 -1
- package/dist/chunk-DVMHRLKP.cjs +1 -1
- package/dist/chunk-EK7FSI7F.cjs +1 -1
- package/dist/chunk-F3WBQKRI.cjs +1 -1
- package/dist/chunk-FI76UZRF.js +1 -1
- package/dist/chunk-GAJBF6DR.js +1 -1
- package/dist/chunk-JY4HLZ4W.js +1 -1
- package/dist/chunk-K3SONK25.cjs +1 -1
- package/dist/chunk-K63WO3XA.cjs +1 -1
- package/dist/chunk-KHO2SBNA.cjs +1 -1
- package/dist/{chunk-TPYENEQ4.cjs → chunk-KIYALQQF.cjs} +44 -9
- package/dist/chunk-KPCDDYTZ.js +1 -1
- package/dist/chunk-KTQLDIIT.cjs +1 -1
- package/dist/chunk-L5RDAVVH.js +1 -1
- package/dist/chunk-LEX4TQW2.js +1 -1
- package/dist/chunk-LIU4S3JA.cjs +1 -1
- package/dist/chunk-NREACG6M.cjs +1 -1
- package/dist/chunk-OFBFGFVH.js +1 -1
- package/dist/chunk-ONZFBJVW.js +1 -1
- package/dist/chunk-OS5OT5JA.cjs +1 -1
- package/dist/chunk-PZQC3FZY.js +1 -1
- package/dist/chunk-QAPYHLHC.cjs +1 -1
- package/dist/chunk-QNKGP5DY.js +1 -1
- package/dist/chunk-QUITZ3GP.js +1 -1
- package/dist/{chunk-H5NWBTHW.cjs → chunk-R3PBF6F7.cjs} +11 -11
- package/dist/chunk-RMJC3B5P.cjs +1 -1
- package/dist/chunk-SZJ7OI4S.js +1 -1
- package/dist/chunk-TDPYR5JY.js +1 -1
- package/dist/chunk-TDYGYHSH.js +1 -1
- package/dist/chunk-TFDXRT6D.cjs +1 -1
- package/dist/{chunk-SN6YRDLG.js → chunk-U5VR4TJN.js} +1 -1
- package/dist/chunk-UDA26MCU.cjs +1 -1
- package/dist/chunk-UKAUXY2U.cjs +1 -1
- package/dist/chunk-VCVND6CH.js +1 -1
- package/dist/chunk-VJDDGRIK.cjs +1 -1
- package/dist/chunk-VJVCXEH7.cjs +1997 -0
- package/dist/chunk-VNADVWSJ.js +1 -1
- package/dist/chunk-WNO3EPYT.js +170 -0
- package/dist/chunk-WVSPXFTY.js +1 -1
- package/dist/chunk-XFTUHS4Y.js +1 -1
- package/dist/chunk-YC7AK3KX.cjs +1 -1
- package/dist/chunk-YGB2BQPB.cjs +1 -1
- package/dist/chunk-YS27V6LS.js +1994 -0
- package/dist/chunk-YWHHVDT4.js +1 -1
- package/dist/chunk-ZN53RM3R.js +1 -1
- package/dist/conversions/index.cjs +1 -1
- package/dist/conversions/index.d.ts +1 -1
- package/dist/conversions/index.js +1 -1
- package/dist/events/index.cjs +1 -1
- package/dist/events/index.d.ts +1 -1
- package/dist/events/index.js +1 -1
- package/dist/formatters/index.cjs +1 -1
- package/dist/formatters/index.d.ts +1 -1
- package/dist/formatters/index.js +1 -1
- package/dist/generators/index.cjs +1 -1
- package/dist/generators/index.d.ts +1 -1
- package/dist/generators/index.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/isPlainObject-FWmcJF6k.d.ts +1 -1
- package/dist/next/index.cjs +9 -8
- package/dist/next/index.d.ts +1 -1
- package/dist/next/index.js +3 -2
- package/dist/next/server/index.cjs +1 -1
- package/dist/next/server/index.d.ts +1 -1
- package/dist/next/server/index.js +1 -1
- package/dist/operations/index.cjs +1 -1
- package/dist/operations/index.d.ts +1 -1
- package/dist/operations/index.js +1 -1
- package/dist/parsers/index.cjs +1 -1
- package/dist/parsers/index.d.ts +1 -1
- package/dist/parsers/index.js +1 -1
- package/dist/predicates/index.cjs +33 -28
- package/dist/predicates/index.d.ts +142 -2
- package/dist/predicates/index.js +3 -2
- package/dist/promises/index.cjs +1 -1
- package/dist/promises/index.d.ts +1 -1
- package/dist/promises/index.js +1 -1
- package/dist/rzl-utils.global.js +2 -2
- package/dist/strings/index.cjs +1 -1
- package/dist/strings/index.d.ts +1 -1
- package/dist/strings/index.js +1 -1
- package/dist/tailwind/index.cjs +13 -9
- package/dist/tailwind/index.d.ts +124 -19
- package/dist/tailwind/index.js +2 -2
- package/dist/urls/index.cjs +14 -9
- package/dist/urls/index.d.ts +268 -19
- package/dist/urls/index.js +4 -3
- package/package.json +11 -3
- package/dist/chunk-LBNOZIZ6.js +0 -90
- package/dist/chunk-URDI3IMY.cjs +0 -93
package/dist/chunk-VNADVWSJ.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* ====================================================
|
|
3
3
|
* Rzl Utils-JS.
|
|
4
4
|
* ----------------------------------------------------
|
|
5
|
-
* Version: 3.
|
|
5
|
+
* Version: 3.7.0.
|
|
6
6
|
* Author: Rizalvin Dwiky.
|
|
7
7
|
* Repository: https://github.com/rzl-zone/utils-js.
|
|
8
8
|
* ====================================================
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* ====================================================
|
|
3
|
+
* Rzl Utils-JS.
|
|
4
|
+
* ----------------------------------------------------
|
|
5
|
+
* Version: 3.7.0.
|
|
6
|
+
* Author: Rizalvin Dwiky.
|
|
7
|
+
* Repository: https://github.com/rzl-zone/utils-js.
|
|
8
|
+
* ====================================================
|
|
9
|
+
*/
|
|
10
|
+
import { isValidDomain } from './chunk-YS27V6LS.js';
|
|
11
|
+
import { removeSpaces } from './chunk-4ACKNPL5.js';
|
|
12
|
+
import { isEmptyString } from './chunk-JY4HLZ4W.js';
|
|
13
|
+
import { safeStableStringify } from './chunk-2VO2CBTU.js';
|
|
14
|
+
import { assertIsPlainObject, isNonEmptyString, getPreciseType, assertIsBoolean, isNil, isString, isNull, isError, hasOwnProp, isBoolean, isFunction } from './chunk-3KTD3QDI.js';
|
|
15
|
+
|
|
16
|
+
var NormalizePathnameError = class _NormalizePathnameError extends Error {
|
|
17
|
+
/** * ***The original error that triggered this normalization failure.***
|
|
18
|
+
*
|
|
19
|
+
* **Always available for backward compatibility.**
|
|
20
|
+
*/
|
|
21
|
+
originalError;
|
|
22
|
+
constructor(message, originalError) {
|
|
23
|
+
super(message, isFunction(Error) ? { cause: originalError } : void 0);
|
|
24
|
+
this.name = "NormalizePathnameError";
|
|
25
|
+
this.originalError = originalError;
|
|
26
|
+
if (isFunction(Error.captureStackTrace)) {
|
|
27
|
+
Error.captureStackTrace(this, _NormalizePathnameError);
|
|
28
|
+
} else {
|
|
29
|
+
this.stack = new Error(message).stack;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/** * ***Safe JSON representation for logging or IPC.*** */
|
|
33
|
+
toJSON() {
|
|
34
|
+
return {
|
|
35
|
+
name: this.name,
|
|
36
|
+
message: this.message,
|
|
37
|
+
stack: this.stack,
|
|
38
|
+
originalError: {
|
|
39
|
+
name: this.originalError.name,
|
|
40
|
+
message: this.originalError.message,
|
|
41
|
+
stack: this.originalError.stack
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
function normalizePathname(pathname, options = {
|
|
48
|
+
defaultPath: "/",
|
|
49
|
+
keepNullable: false
|
|
50
|
+
}) {
|
|
51
|
+
assertIsPlainObject(options, {
|
|
52
|
+
message({ currentType, validType }) {
|
|
53
|
+
return `Second parameter (\`options\`) must be of type \`${validType}\`, but received: \`${currentType}\`.`;
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
const { defaultPath = "/", keepNullable = false, keepTrailingSlash = false } = options;
|
|
57
|
+
if (!isNonEmptyString(defaultPath)) {
|
|
58
|
+
throw new TypeError(
|
|
59
|
+
`Parameter \`defaultPath\` property of the \`options\` (second parameter) must be of type \`string\` and not empty-string, but received: \`${getPreciseType(
|
|
60
|
+
defaultPath
|
|
61
|
+
)}\`, with value: \`${safeStableStringify(defaultPath)}\`.`
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
assertIsBoolean(keepTrailingSlash, {
|
|
65
|
+
message({ currentType, validType }) {
|
|
66
|
+
return `Parameter \`keepTrailingSlash\` property of the \`options\` (second parameter) must be of type \`${validType}\`, but received: \`${currentType}\`.`;
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
try {
|
|
70
|
+
if (keepNullable && (isNil(pathname) || !isString(pathname))) {
|
|
71
|
+
if (isNull(pathname)) return null;
|
|
72
|
+
return void 0;
|
|
73
|
+
}
|
|
74
|
+
let currentPathName = isNonEmptyString(pathname) ? pathname : defaultPath;
|
|
75
|
+
currentPathName = removeSpaces(currentPathName, { trimOnly: true }).replace(
|
|
76
|
+
/\s+/g,
|
|
77
|
+
""
|
|
78
|
+
);
|
|
79
|
+
currentPathName = stripLeadingDomain(currentPathName);
|
|
80
|
+
let _pathName = currentPathName;
|
|
81
|
+
let search = "";
|
|
82
|
+
let hash = "";
|
|
83
|
+
const searchIndex = currentPathName.indexOf("?");
|
|
84
|
+
const hashIndex = currentPathName.indexOf("#");
|
|
85
|
+
if (searchIndex !== -1) {
|
|
86
|
+
search = currentPathName.slice(
|
|
87
|
+
searchIndex,
|
|
88
|
+
hashIndex !== -1 ? hashIndex : void 0
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
if (hashIndex !== -1) {
|
|
92
|
+
hash = currentPathName.slice(hashIndex);
|
|
93
|
+
}
|
|
94
|
+
const endIndex = Math.min(
|
|
95
|
+
searchIndex !== -1 ? searchIndex : currentPathName.length,
|
|
96
|
+
hashIndex !== -1 ? hashIndex : currentPathName.length
|
|
97
|
+
);
|
|
98
|
+
_pathName = currentPathName.slice(0, endIndex);
|
|
99
|
+
_pathName = "/" + _pathName.replace(/^\/+/, "").replace(/\/{2,}/g, "/");
|
|
100
|
+
if (!keepTrailingSlash && _pathName !== "/") {
|
|
101
|
+
_pathName = _pathName.replace(/\/+$/, "");
|
|
102
|
+
}
|
|
103
|
+
_pathName = decodeUnicodeSequences(_pathName);
|
|
104
|
+
search = decodeUnicodeSequences(search);
|
|
105
|
+
hash = decodeUnicodeSequences(hash);
|
|
106
|
+
return _pathName + search + hash;
|
|
107
|
+
} catch (error) {
|
|
108
|
+
const err = isError(error) ? error : new Error("Unknown error from function `normalizePathname()`.");
|
|
109
|
+
throw new NormalizePathnameError(
|
|
110
|
+
`Failed to normalize pathname in function \`normalizePathname()\`: ${err.message}`,
|
|
111
|
+
err
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
function decodeUnicodeSequences(str) {
|
|
116
|
+
return str.replace(/(?:%(?:[0-9A-F]{2})){2,}/gi, (match) => {
|
|
117
|
+
try {
|
|
118
|
+
const decoded = decodeURIComponent(match);
|
|
119
|
+
if (/^[\u0000-\u007F]+$/.test(decoded)) return match;
|
|
120
|
+
return decoded;
|
|
121
|
+
} catch {
|
|
122
|
+
return match;
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
function stripLeadingDomain(path) {
|
|
127
|
+
let currentPath = path;
|
|
128
|
+
if (/^https?:\/\//i.test(currentPath)) {
|
|
129
|
+
try {
|
|
130
|
+
const url = new URL(currentPath);
|
|
131
|
+
currentPath = "/" + url.pathname.replace(/^\/+/, "").replace(/\/{2,}/g, "/") + url.search + url.hash;
|
|
132
|
+
} catch {
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
if (currentPath.startsWith("/")) {
|
|
136
|
+
currentPath = currentPath.replace(/\/{2,}/g, "/").slice(1);
|
|
137
|
+
}
|
|
138
|
+
const firstPart = currentPath.split("/")[0];
|
|
139
|
+
const domainPart = firstPart.split(":")[0];
|
|
140
|
+
if (isValidDomain(domainPart, {
|
|
141
|
+
subdomain: true,
|
|
142
|
+
allowUnicode: true,
|
|
143
|
+
wildcard: true,
|
|
144
|
+
topLevel: false
|
|
145
|
+
}) || domainPart === "localhost") {
|
|
146
|
+
currentPath = currentPath.slice(firstPart.length);
|
|
147
|
+
}
|
|
148
|
+
if (!currentPath.startsWith("/")) currentPath = "/" + currentPath;
|
|
149
|
+
return currentPath;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
var formatEnvPort = (envVar, options = {}) => {
|
|
153
|
+
if (!isNonEmptyString(envVar)) return "";
|
|
154
|
+
assertIsPlainObject(options, {
|
|
155
|
+
message: ({ currentType, validType }) => `Second parameter (\`options\`) must be of type \`${validType}\`, but received: \`${currentType}\`.`
|
|
156
|
+
});
|
|
157
|
+
const prefixColon = hasOwnProp(options, "prefixColon") ? options.prefixColon : false;
|
|
158
|
+
if (!isBoolean(prefixColon)) {
|
|
159
|
+
throw new TypeError(
|
|
160
|
+
`Parameter \`prefixColon\` property of the \`options\` (second parameter) must be of type \`boolean\`, but received: \`${getPreciseType(
|
|
161
|
+
prefixColon
|
|
162
|
+
)}\`.`
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
const digitsOnly = envVar.replace(/\D+/g, "");
|
|
166
|
+
if (isEmptyString(digitsOnly)) return "";
|
|
167
|
+
return prefixColon ? `:${digitsOnly}` : digitsOnly;
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
export { formatEnvPort, normalizePathname };
|
package/dist/chunk-WVSPXFTY.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* ====================================================
|
|
3
3
|
* Rzl Utils-JS.
|
|
4
4
|
* ----------------------------------------------------
|
|
5
|
-
* Version: 3.
|
|
5
|
+
* Version: 3.7.0.
|
|
6
6
|
* Author: Rizalvin Dwiky.
|
|
7
7
|
* Repository: https://github.com/rzl-zone/utils-js.
|
|
8
8
|
* ====================================================
|
package/dist/chunk-XFTUHS4Y.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* ====================================================
|
|
3
3
|
* Rzl Utils-JS.
|
|
4
4
|
* ----------------------------------------------------
|
|
5
|
-
* Version: 3.
|
|
5
|
+
* Version: 3.7.0.
|
|
6
6
|
* Author: Rizalvin Dwiky.
|
|
7
7
|
* Repository: https://github.com/rzl-zone/utils-js.
|
|
8
8
|
* ====================================================
|
package/dist/chunk-YC7AK3KX.cjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* ====================================================
|
|
3
3
|
* Rzl Utils-JS.
|
|
4
4
|
* ----------------------------------------------------
|
|
5
|
-
* Version: 3.
|
|
5
|
+
* Version: 3.7.0.
|
|
6
6
|
* Author: Rizalvin Dwiky.
|
|
7
7
|
* Repository: https://github.com/rzl-zone/utils-js.
|
|
8
8
|
* ====================================================
|
package/dist/chunk-YGB2BQPB.cjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* ====================================================
|
|
3
3
|
* Rzl Utils-JS.
|
|
4
4
|
* ----------------------------------------------------
|
|
5
|
-
* Version: 3.
|
|
5
|
+
* Version: 3.7.0.
|
|
6
6
|
* Author: Rizalvin Dwiky.
|
|
7
7
|
* Repository: https://github.com/rzl-zone/utils-js.
|
|
8
8
|
* ====================================================
|