@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.
- package/README.md +28 -1
- package/dist/assertions/index.cjs +11 -11
- package/dist/assertions/index.d.ts +169 -58
- package/dist/assertions/index.js +5 -5
- package/dist/{chunk-EK7FSI7F.cjs → chunk-2XGQQZ6A.cjs} +3 -3
- package/dist/{chunk-YS27V6LS.js → chunk-3LE6NX57.js} +5 -176
- package/dist/{chunk-PZQC3FZY.js → chunk-44X74C26.js} +4 -4
- package/dist/{chunk-4ACKNPL5.js → chunk-5KDVIEVO.js} +2 -2
- package/dist/{chunk-JY4HLZ4W.js → chunk-5O66AUEC.js} +2 -2
- package/dist/chunk-5Y6JL47L.js +302 -0
- package/dist/{chunk-KIYALQQF.cjs → chunk-62FS7WMB.cjs} +35 -35
- package/dist/{chunk-VJVCXEH7.cjs → chunk-6AMDHVS2.cjs} +9 -181
- package/dist/{chunk-6PKW4WCT.js → chunk-6WVOUVWD.js} +27 -15
- package/dist/{chunk-BYUT376O.cjs → chunk-76ATVDCR.cjs} +3 -3
- package/dist/{chunk-F3WBQKRI.cjs → chunk-7C7TQC5J.cjs} +29 -7
- package/dist/{chunk-QUITZ3GP.js → chunk-7EIFPHV3.js} +32 -16
- package/dist/{chunk-6RFNZ2ZZ.cjs → chunk-7NXFGJJE.cjs} +14 -14
- package/dist/{chunk-TFDXRT6D.cjs → chunk-ALRISPTL.cjs} +3 -3
- package/dist/chunk-BAV5T2E3.cjs +1 -1
- package/dist/{chunk-4ZOXSUXB.js → chunk-C7GC2PFX.js} +3 -3
- package/dist/chunk-DVMHRLKP.cjs +1 -1
- package/dist/{chunk-XFTUHS4Y.js → chunk-DXPM4NOU.js} +10 -8
- package/dist/{chunk-DPLL67OT.js → chunk-EJV5AF4L.js} +2 -2
- package/dist/{chunk-NREACG6M.cjs → chunk-FWWPEL7J.cjs} +3 -3
- package/dist/{chunk-LEX4TQW2.js → chunk-GHU356XQ.js} +4 -6
- package/dist/chunk-GKDSBOYE.js +209 -0
- package/dist/{chunk-YC7AK3KX.cjs → chunk-H44QVAZL.cjs} +31 -31
- package/dist/{chunk-AKKM6MOX.cjs → chunk-I33PB44Q.cjs} +15 -15
- package/dist/{chunk-LIU4S3JA.cjs → chunk-IX6PF5ZP.cjs} +4 -4
- package/dist/{chunk-3KTD3QDI.js → chunk-J4TT33ZX.js} +29 -7
- package/dist/{chunk-SZJ7OI4S.js → chunk-J6VLFVIL.js} +3 -3
- package/dist/{chunk-KTQLDIIT.cjs → chunk-JI57K7D4.cjs} +173 -163
- package/dist/{chunk-OFBFGFVH.js → chunk-JYOCB6OV.js} +2 -2
- package/dist/chunk-KHO2SBNA.cjs +1 -1
- package/dist/{chunk-66WLOZOD.cjs → chunk-KUVRZ2JW.cjs} +53 -51
- package/dist/chunk-L5RDAVVH.js +1 -1
- package/dist/{chunk-VCVND6CH.js → chunk-M5QB2GM5.js} +2 -2
- package/dist/{chunk-3LEWQV3R.js → chunk-MBFVTGYS.js} +8 -8
- package/dist/{chunk-UKAUXY2U.cjs → chunk-MMRHKYT6.cjs} +12 -12
- package/dist/{chunk-U5VR4TJN.js → chunk-MS2KSKD7.js} +9 -9
- package/dist/{chunk-7ZNEUWYP.js → chunk-MZ3T6L7Z.js} +2 -2
- package/dist/{chunk-ATLFMKAF.cjs → chunk-NAOVH4OH.cjs} +7 -7
- package/dist/chunk-NJ24M6ZH.cjs +308 -0
- package/dist/chunk-OCTHWEZK.cjs +249 -0
- package/dist/chunk-ONZFBJVW.js +1 -1
- package/dist/{chunk-FI76UZRF.js → chunk-OSSFLQDD.js} +3 -4
- package/dist/{chunk-7WBMA2VE.cjs → chunk-OYFUBKEG.cjs} +4 -5
- package/dist/{chunk-B4SDEBN7.cjs → chunk-PWKOFPAH.cjs} +3 -3
- package/dist/{chunk-2CQI36UD.cjs → chunk-QGTFQ7RO.cjs} +8 -6
- package/dist/chunk-QNKGP5DY.js +1 -1
- package/dist/chunk-QXTJVDWE.js +676 -0
- package/dist/{chunk-B6UIKBHR.cjs → chunk-QZI5PVCI.cjs} +4 -4
- package/dist/{chunk-WNO3EPYT.js → chunk-R2DR7SPJ.js} +102 -26
- package/dist/{chunk-TDYGYHSH.js → chunk-SN5HAK3Y.js} +4 -4
- package/dist/{chunk-D53CE4BT.js → chunk-SRWL4YCP.js} +11 -8
- package/dist/{chunk-7QQV66RX.cjs → chunk-TJ5OY6MC.cjs} +10 -10
- package/dist/{chunk-6WMB5AJR.js → chunk-TXOVQZPU.js} +3 -4
- package/dist/chunk-UDA26MCU.cjs +1 -1
- package/dist/{chunk-R3PBF6F7.cjs → chunk-UFYMRRJH.cjs} +73 -61
- package/dist/{chunk-5NN4ZDE2.cjs → chunk-UV5BKAYW.cjs} +6 -8
- package/dist/{chunk-GAJBF6DR.js → chunk-UXT4XSUK.js} +2 -2
- package/dist/{chunk-TDPYR5JY.js → chunk-VBSLIIDB.js} +24 -14
- package/dist/chunk-VCYXNIZ2.cjs +678 -0
- package/dist/chunk-VJDDGRIK.cjs +1 -1
- package/dist/{chunk-VNADVWSJ.js → chunk-WB3FT62A.js} +6 -4
- package/dist/{chunk-K63WO3XA.cjs → chunk-WKM6UVMG.cjs} +4 -5
- package/dist/{chunk-OS5OT5JA.cjs → chunk-WLEZ2KSG.cjs} +142 -126
- package/dist/{chunk-ZN53RM3R.js → chunk-WRGN6UBK.js} +2 -2
- package/dist/chunk-WVSPXFTY.js +1 -1
- package/dist/{chunk-2VO2CBTU.js → chunk-X6ULJZ3X.js} +2 -2
- package/dist/{chunk-CKUEZF4R.cjs → chunk-XYWC4EQ3.cjs} +71 -71
- package/dist/{chunk-A3YI6Y2P.js → chunk-YHFRCVTN.js} +3 -3
- package/dist/{chunk-RMJC3B5P.cjs → chunk-YQHJB7KR.cjs} +30 -27
- package/dist/{chunk-YGB2BQPB.cjs → chunk-YVRUY4EW.cjs} +8 -8
- package/dist/chunk-YWHHVDT4.js +1 -1
- package/dist/chunk-ZTHJQJ5F.cjs +211 -0
- package/dist/conversions/index.cjs +34 -34
- package/dist/conversions/index.d.ts +10 -12
- package/dist/conversions/index.js +15 -15
- package/dist/events/index.cjs +8 -8
- package/dist/events/index.d.ts +9 -9
- package/dist/events/index.js +4 -4
- package/dist/formatters/index.cjs +19 -19
- package/dist/formatters/index.d.ts +19 -24
- package/dist/formatters/index.js +9 -9
- package/dist/generators/index.cjs +12 -8
- package/dist/generators/index.d.ts +155 -26
- package/dist/generators/index.js +4 -4
- package/dist/index.d.ts +1 -1
- package/dist/{isPlainObject-FWmcJF6k.d.ts → isPlainObject-BTPjv6zB.d.ts} +2 -2
- package/dist/next/index.cjs +39 -36
- package/dist/next/index.d.ts +11 -11
- package/dist/next/index.js +12 -9
- package/dist/next/server/index.cjs +4 -4
- package/dist/next/server/index.d.ts +4 -4
- package/dist/next/server/index.js +2 -2
- package/dist/operations/index.cjs +11 -11
- package/dist/operations/index.d.ts +8 -9
- package/dist/operations/index.js +8 -8
- package/dist/parsers/index.cjs +6 -4
- package/dist/parsers/index.d.ts +224 -32
- package/dist/parsers/index.js +5 -3
- package/dist/predicates/index.cjs +77 -76
- package/dist/predicates/index.d.ts +15 -28
- package/dist/predicates/index.js +14 -13
- package/dist/promises/index.cjs +6 -6
- package/dist/promises/index.d.ts +5 -7
- package/dist/promises/index.js +4 -4
- package/dist/rzl-utils.global.js +2 -2
- 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 +13 -13
- package/dist/tailwind/index.d.ts +18 -18
- package/dist/tailwind/index.js +5 -5
- package/dist/urls/index.cjs +23 -21
- package/dist/urls/index.d.ts +188 -121
- package/dist/urls/index.js +16 -14
- package/package.json +1 -1
- package/dist/chunk-ABA2ZSBQ.js +0 -152
- package/dist/chunk-BG3AS5BU.cjs +0 -173
- package/dist/chunk-K3SONK25.cjs +0 -157
- package/dist/chunk-KPCDDYTZ.js +0 -417
- package/dist/chunk-QAPYHLHC.cjs +0 -419
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* ====================================================
|
|
3
3
|
* Rzl Utils-JS.
|
|
4
4
|
* ----------------------------------------------------
|
|
5
|
-
* Version: 3.
|
|
5
|
+
* Version: 3.9.0.
|
|
6
6
|
* Author: Rizalvin Dwiky.
|
|
7
7
|
* Repository: https://github.com/rzl-zone/utils-js.
|
|
8
8
|
* ====================================================
|
|
@@ -10,60 +10,60 @@
|
|
|
10
10
|
'use strict';
|
|
11
11
|
|
|
12
12
|
var chunkUDA26MCU_cjs = require('./chunk-UDA26MCU.cjs');
|
|
13
|
-
var
|
|
13
|
+
var chunk7C7TQC5J_cjs = require('./chunk-7C7TQC5J.cjs');
|
|
14
14
|
|
|
15
15
|
function isMap(value) {
|
|
16
16
|
return Object.prototype.toString.call(value) === "[object Map]" || value instanceof Map;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
var isDate = (value, options = {}) => {
|
|
20
|
-
|
|
20
|
+
chunk7C7TQC5J_cjs.assertIsPlainObject(options, {
|
|
21
21
|
message: ({ currentType, validType }) => `Second parameter (\`options\`) must be of type \`${validType}\`, but received: \`${currentType}\`.`
|
|
22
22
|
});
|
|
23
|
-
const skipInvalidDate =
|
|
23
|
+
const skipInvalidDate = chunk7C7TQC5J_cjs.isPlainObject(options) && chunk7C7TQC5J_cjs.isBoolean(options.skipInvalidDate) ? options.skipInvalidDate : false;
|
|
24
24
|
const instanceDate = value instanceof Date;
|
|
25
25
|
if (skipInvalidDate) return instanceDate;
|
|
26
|
-
return instanceDate && !
|
|
26
|
+
return instanceDate && !chunk7C7TQC5J_cjs.isNaN(value.getTime());
|
|
27
27
|
};
|
|
28
28
|
|
|
29
29
|
var safeStableStringify = (value, options = {}) => {
|
|
30
|
-
|
|
30
|
+
chunk7C7TQC5J_cjs.assertIsPlainObject(options, {
|
|
31
31
|
message: ({ currentType, validType }) => `Second parameter (\`options\`) must be of type \`${validType}\`, but received: \`${currentType}\`.`
|
|
32
32
|
});
|
|
33
|
-
const pretty =
|
|
34
|
-
const sortKeys =
|
|
35
|
-
const sortArray =
|
|
36
|
-
const keepUndefined =
|
|
37
|
-
if (!
|
|
33
|
+
const pretty = chunk7C7TQC5J_cjs.hasOwnProp(options, "pretty") ? options.pretty : false;
|
|
34
|
+
const sortKeys = chunk7C7TQC5J_cjs.hasOwnProp(options, "sortKeys") ? options.sortKeys : true;
|
|
35
|
+
const sortArray = chunk7C7TQC5J_cjs.hasOwnProp(options, "sortArray") ? options.sortArray : false;
|
|
36
|
+
const keepUndefined = chunk7C7TQC5J_cjs.hasOwnProp(options, "keepUndefined") ? options.keepUndefined : false;
|
|
37
|
+
if (!chunk7C7TQC5J_cjs.isBoolean(sortKeys) || !chunk7C7TQC5J_cjs.isBoolean(sortArray) || !chunk7C7TQC5J_cjs.isBoolean(pretty) || !chunk7C7TQC5J_cjs.isBoolean(keepUndefined)) {
|
|
38
38
|
throw new TypeError(
|
|
39
|
-
`Parameters \`sortKeys\`, \`sortArray\`, \`keepUndefined\` and \`pretty\` property of the \`options\` (second parameter) must be of type \`boolean\`, but received: "['sortKeys': \`${
|
|
39
|
+
`Parameters \`sortKeys\`, \`sortArray\`, \`keepUndefined\` and \`pretty\` property of the \`options\` (second parameter) must be of type \`boolean\`, but received: "['sortKeys': \`${chunk7C7TQC5J_cjs.getPreciseType(
|
|
40
40
|
sortKeys
|
|
41
|
-
)}\`, 'sortArray': \`${
|
|
41
|
+
)}\`, 'sortArray': \`${chunk7C7TQC5J_cjs.getPreciseType(
|
|
42
42
|
sortArray
|
|
43
|
-
)}\`, 'keepUndefined': \`${
|
|
43
|
+
)}\`, 'keepUndefined': \`${chunk7C7TQC5J_cjs.getPreciseType(
|
|
44
44
|
keepUndefined
|
|
45
|
-
)}\`, 'pretty': \`${
|
|
45
|
+
)}\`, 'pretty': \`${chunk7C7TQC5J_cjs.getPreciseType(pretty)}\`]".`
|
|
46
46
|
);
|
|
47
47
|
}
|
|
48
|
-
if (
|
|
48
|
+
if (chunk7C7TQC5J_cjs.isUndefined(value)) {
|
|
49
49
|
return keepUndefined ? "undefined" : "null";
|
|
50
50
|
}
|
|
51
51
|
const seen = /* @__PURE__ */ new WeakSet();
|
|
52
|
-
const isPrimitive = (val) =>
|
|
52
|
+
const isPrimitive = (val) => chunk7C7TQC5J_cjs.isNull(val) || !chunk7C7TQC5J_cjs.isObjectOrArray(val) && !chunk7C7TQC5J_cjs.isFunction(val);
|
|
53
53
|
const deepProcess = (val) => {
|
|
54
|
-
if (
|
|
54
|
+
if (chunk7C7TQC5J_cjs.isNumberObject(val)) {
|
|
55
55
|
const valOf = val.valueOf();
|
|
56
|
-
return
|
|
56
|
+
return chunk7C7TQC5J_cjs.isNaN(valOf) || chunk7C7TQC5J_cjs.isInfinityNumber(valOf) ? null : valOf;
|
|
57
57
|
}
|
|
58
|
-
if (
|
|
59
|
-
if (
|
|
60
|
-
if (
|
|
58
|
+
if (chunk7C7TQC5J_cjs.isStringObject(val)) return val.valueOf();
|
|
59
|
+
if (chunk7C7TQC5J_cjs.isBooleanObject(val)) return val.valueOf();
|
|
60
|
+
if (chunk7C7TQC5J_cjs.isFunction(val) || chunk7C7TQC5J_cjs.isSymbol(val)) return void 0;
|
|
61
61
|
if (chunkUDA26MCU_cjs.isBigInt(val)) return val.toString();
|
|
62
|
-
if (
|
|
63
|
-
if (
|
|
62
|
+
if (chunk7C7TQC5J_cjs.isNaN(val) || chunk7C7TQC5J_cjs.isInfinityNumber(val)) return null;
|
|
63
|
+
if (chunk7C7TQC5J_cjs.isUndefined(val)) {
|
|
64
64
|
return keepUndefined ? void 0 : null;
|
|
65
65
|
}
|
|
66
|
-
if (
|
|
66
|
+
if (chunk7C7TQC5J_cjs.isObjectOrArray(val)) {
|
|
67
67
|
if (seen.has(val)) return "[Circular]";
|
|
68
68
|
seen.add(val);
|
|
69
69
|
if (isDate(val)) return val.toISOString();
|
|
@@ -72,8 +72,8 @@ var safeStableStringify = (value, options = {}) => {
|
|
|
72
72
|
map: Array.from(val.entries()).map(([k, v]) => [k, deepProcess(v)])
|
|
73
73
|
};
|
|
74
74
|
}
|
|
75
|
-
if (
|
|
76
|
-
if (
|
|
75
|
+
if (chunk7C7TQC5J_cjs.isSet(val)) return { set: Array.from(val.values()).map(deepProcess) };
|
|
76
|
+
if (chunk7C7TQC5J_cjs.isArray(val)) {
|
|
77
77
|
const processedArr = val.map(deepProcess);
|
|
78
78
|
if (sortArray) {
|
|
79
79
|
const primitives = [];
|
|
@@ -83,7 +83,7 @@ var safeStableStringify = (value, options = {}) => {
|
|
|
83
83
|
else nonPrimitives.push(item);
|
|
84
84
|
}
|
|
85
85
|
primitives.sort((a, b) => {
|
|
86
|
-
if (
|
|
86
|
+
if (chunk7C7TQC5J_cjs.isNumber(a) && chunk7C7TQC5J_cjs.isNumber(b)) return a - b;
|
|
87
87
|
return String(a).localeCompare(String(b));
|
|
88
88
|
});
|
|
89
89
|
return [...primitives, ...nonPrimitives];
|
|
@@ -95,15 +95,15 @@ var safeStableStringify = (value, options = {}) => {
|
|
|
95
95
|
keys.sort((a, b) => {
|
|
96
96
|
const na = Number(a);
|
|
97
97
|
const nb = Number(b);
|
|
98
|
-
if (!
|
|
98
|
+
if (!chunk7C7TQC5J_cjs.isNaN(na) && !chunk7C7TQC5J_cjs.isNaN(nb)) return na - nb;
|
|
99
99
|
return a.localeCompare(b);
|
|
100
100
|
});
|
|
101
101
|
}
|
|
102
102
|
const result = {};
|
|
103
|
-
if (
|
|
103
|
+
if (chunk7C7TQC5J_cjs.isObject(val)) {
|
|
104
104
|
for (const k of keys) {
|
|
105
105
|
const v = deepProcess(val[k]);
|
|
106
|
-
if (!
|
|
106
|
+
if (!chunk7C7TQC5J_cjs.isUndefined(v)) result[k] = v;
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
109
|
return result;
|
|
@@ -2,26 +2,26 @@
|
|
|
2
2
|
* ====================================================
|
|
3
3
|
* Rzl Utils-JS.
|
|
4
4
|
* ----------------------------------------------------
|
|
5
|
-
* Version: 3.
|
|
5
|
+
* Version: 3.9.0.
|
|
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
|
|
13
|
-
var
|
|
12
|
+
var chunkPWKOFPAH_cjs = require('./chunk-PWKOFPAH.cjs');
|
|
13
|
+
var chunkNAOVH4OH_cjs = require('./chunk-NAOVH4OH.cjs');
|
|
14
14
|
var chunkUDA26MCU_cjs = require('./chunk-UDA26MCU.cjs');
|
|
15
|
-
var
|
|
15
|
+
var chunk7C7TQC5J_cjs = require('./chunk-7C7TQC5J.cjs');
|
|
16
16
|
|
|
17
17
|
function filterNilArray(input) {
|
|
18
|
-
if (
|
|
19
|
-
if (!
|
|
18
|
+
if (chunk7C7TQC5J_cjs.isNil(input)) return void 0;
|
|
19
|
+
if (!chunk7C7TQC5J_cjs.isArray(input)) return [];
|
|
20
20
|
const filtered = input.reduce((output, element) => {
|
|
21
|
-
if (!
|
|
22
|
-
if (
|
|
21
|
+
if (!chunk7C7TQC5J_cjs.isNil(element)) {
|
|
22
|
+
if (chunk7C7TQC5J_cjs.isArray(element)) {
|
|
23
23
|
const cleanedNested = filterNilArray(element);
|
|
24
|
-
if (cleanedNested && !
|
|
24
|
+
if (cleanedNested && !chunkNAOVH4OH_cjs.isEmptyArray(cleanedNested)) {
|
|
25
25
|
output.push(cleanedNested);
|
|
26
26
|
}
|
|
27
27
|
} else {
|
|
@@ -34,17 +34,17 @@ function filterNilArray(input) {
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
function toStringArrayUnRecursive(array, options = {}) {
|
|
37
|
-
|
|
37
|
+
chunk7C7TQC5J_cjs.assertIsPlainObject(options, {
|
|
38
38
|
message: ({ currentType, validType }) => `Second parameter (\`options\`) must be of type \`${validType}\`, but received: \`${currentType}\`.`
|
|
39
39
|
});
|
|
40
|
-
const riv =
|
|
41
|
-
|
|
40
|
+
const riv = chunk7C7TQC5J_cjs.hasOwnProp(options, "removeInvalidValue") ? options.removeInvalidValue : true;
|
|
41
|
+
chunk7C7TQC5J_cjs.assertIsBoolean(riv, {
|
|
42
42
|
message: ({ currentType, validType }) => `Parameter \`removeInvalidValue\` property of the \`options\` (second parameter) must be of type \`${validType}\`, but received: \`${currentType}\`.`
|
|
43
43
|
});
|
|
44
|
-
if (
|
|
44
|
+
if (chunk7C7TQC5J_cjs.isArray(array)) {
|
|
45
45
|
const result = Array.from(array, (x) => {
|
|
46
|
-
if (
|
|
47
|
-
return
|
|
46
|
+
if (chunk7C7TQC5J_cjs.isString(x) || chunkPWKOFPAH_cjs.isFinite(x) || chunk7C7TQC5J_cjs.isBoolean(x) || chunkUDA26MCU_cjs.isBigInt(x)) return String(x);
|
|
47
|
+
return chunk7C7TQC5J_cjs.isNull(x) ? null : void 0;
|
|
48
48
|
});
|
|
49
49
|
if (riv) return filterNilArray(result);
|
|
50
50
|
return result;
|
|
@@ -2,20 +2,20 @@
|
|
|
2
2
|
* ====================================================
|
|
3
3
|
* Rzl Utils-JS.
|
|
4
4
|
* ----------------------------------------------------
|
|
5
|
-
* Version: 3.
|
|
5
|
+
* Version: 3.9.0.
|
|
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 chunk7C7TQC5J_cjs = require('./chunk-7C7TQC5J.cjs');
|
|
13
13
|
|
|
14
14
|
var removeSpaces = (value, options = {
|
|
15
15
|
trimOnly: false
|
|
16
16
|
}) => {
|
|
17
|
-
if (!
|
|
18
|
-
if (!
|
|
17
|
+
if (!chunk7C7TQC5J_cjs.isNonEmptyString(value)) return "";
|
|
18
|
+
if (!chunk7C7TQC5J_cjs.isPlainObject(options)) {
|
|
19
19
|
options = {};
|
|
20
20
|
}
|
|
21
21
|
const { trimOnly = false } = options;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* ====================================================
|
|
3
3
|
* Rzl Utils-JS.
|
|
4
4
|
* ----------------------------------------------------
|
|
5
|
-
* Version: 3.
|
|
5
|
+
* Version: 3.9.0.
|
|
6
6
|
* Author: Rizalvin Dwiky.
|
|
7
7
|
* Repository: https://github.com/rzl-zone/utils-js.
|
|
8
8
|
* ====================================================
|
|
@@ -49,12 +49,11 @@ var isNull = (val) => val === null;
|
|
|
49
49
|
|
|
50
50
|
var assertIsBoolean = (value, options = {}) => {
|
|
51
51
|
if (isBoolean(value)) return;
|
|
52
|
-
|
|
52
|
+
resolveErrorMessageAssertions({
|
|
53
53
|
value,
|
|
54
54
|
options,
|
|
55
55
|
requiredValidType: "boolean"
|
|
56
56
|
});
|
|
57
|
-
throw new TypeError(errorMessage);
|
|
58
57
|
};
|
|
59
58
|
|
|
60
59
|
var isNumber = (value, options = {}) => {
|
|
@@ -538,25 +537,48 @@ var getPreciseType = (value, options = { formatCase: "toLowerCase" }) => {
|
|
|
538
537
|
}
|
|
539
538
|
return converterHelper(tag, formatCase);
|
|
540
539
|
};
|
|
540
|
+
var determineErrorTypeAssertion = (type, message) => {
|
|
541
|
+
switch (type) {
|
|
542
|
+
case "Error":
|
|
543
|
+
throw new Error(message);
|
|
544
|
+
case "EvalError":
|
|
545
|
+
throw new EvalError(message);
|
|
546
|
+
case "RangeError":
|
|
547
|
+
throw new RangeError(message);
|
|
548
|
+
case "ReferenceError":
|
|
549
|
+
throw new ReferenceError(message);
|
|
550
|
+
case "SyntaxError":
|
|
551
|
+
throw new SyntaxError(message);
|
|
552
|
+
case "URIError":
|
|
553
|
+
throw new URIError(message);
|
|
554
|
+
case "TypeError":
|
|
555
|
+
throw new TypeError(message);
|
|
556
|
+
default:
|
|
557
|
+
throw new TypeError(message);
|
|
558
|
+
}
|
|
559
|
+
};
|
|
541
560
|
function resolveErrorMessageAssertions(params) {
|
|
542
561
|
const { requiredValidType, value, options } = params || {};
|
|
543
|
-
const {
|
|
562
|
+
const {
|
|
563
|
+
message,
|
|
564
|
+
formatCase,
|
|
565
|
+
errorType = "TypeError"
|
|
566
|
+
} = isPlainObject(options) ? options : {};
|
|
544
567
|
const validType2 = toKebabCase(requiredValidType);
|
|
545
568
|
const currentType = getPreciseType(value, { formatCase });
|
|
546
569
|
const messageFnOptions = { currentType, validType: validType2 };
|
|
547
570
|
const defaultMessage = `Parameter input (\`value\`) must be of type \`${validType2}\`, but received: \`${currentType}\`.`;
|
|
548
571
|
const errorMessage = isFunction(message) ? isNonEmptyString(message(messageFnOptions)) ? message(messageFnOptions).trim() : defaultMessage : isNonEmptyString(message) ? message.trim() : defaultMessage;
|
|
549
|
-
return errorMessage;
|
|
572
|
+
return determineErrorTypeAssertion(errorType, errorMessage);
|
|
550
573
|
}
|
|
551
574
|
|
|
552
575
|
function assertIsPlainObject(value, options = {}) {
|
|
553
576
|
if (isPlainObject(value)) return;
|
|
554
|
-
|
|
577
|
+
resolveErrorMessageAssertions({
|
|
555
578
|
value,
|
|
556
579
|
options,
|
|
557
580
|
requiredValidType: "plain object"
|
|
558
581
|
});
|
|
559
|
-
throw new TypeError(errorMessage);
|
|
560
582
|
}
|
|
561
583
|
|
|
562
584
|
export { assertIsBoolean, assertIsPlainObject, getPreciseType, hasOwnProp, isArray, isBoolean, isBooleanObject, isBuffer, isError, isFunction, isInfinityNumber, isNaN, isNil, isNonEmptyArray, isNonEmptyString, isNull, isNumber, isNumberObject, isObject, isObjectOrArray, isPlainObject, isSet, isString, isStringObject, isSymbol, isUndefined, resolveErrorMessageAssertions, slugify, toCamelCase, toDotCase, toKebabCase, toLowerCase, toPascalCase, toPascalCaseSpace, toSnakeCase };
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
* ====================================================
|
|
3
3
|
* Rzl Utils-JS.
|
|
4
4
|
* ----------------------------------------------------
|
|
5
|
-
* Version: 3.
|
|
5
|
+
* Version: 3.9.0.
|
|
6
6
|
* Author: Rizalvin Dwiky.
|
|
7
7
|
* Repository: https://github.com/rzl-zone/utils-js.
|
|
8
8
|
* ====================================================
|
|
9
9
|
*/
|
|
10
|
-
import { isDate, isMap } from './chunk-
|
|
11
|
-
import { isObjectOrArray, isError, isSet, isArray, isUndefined } from './chunk-
|
|
10
|
+
import { isDate, isMap } from './chunk-X6ULJZ3X.js';
|
|
11
|
+
import { isObjectOrArray, isError, isSet, isArray, isUndefined } from './chunk-J4TT33ZX.js';
|
|
12
12
|
|
|
13
13
|
var isRegExp = (value) => {
|
|
14
14
|
return value instanceof RegExp;
|