@rzl-zone/utils-js 3.11.1 → 3.12.1-beta.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/{LICENSE.md → LICENSE} +3 -3
- package/README.md +62 -89
- package/dist/.references/index.d.cts +25 -0
- package/dist/.references/index.d.ts +25 -0
- package/dist/assertIsArray-BChqwPiP.cjs +26 -0
- package/dist/assertIsArray-BChqwPiP.cjs.map +1 -0
- package/dist/assertIsArray-BfAbIUfa.js +20 -0
- package/dist/assertIsArray-BfAbIUfa.js.map +1 -0
- package/dist/assertIsBoolean-BlBct0Fc.js +1073 -0
- package/dist/assertIsBoolean-BlBct0Fc.js.map +1 -0
- package/dist/assertIsBoolean-DozdtbNi.cjs +1283 -0
- package/dist/assertIsBoolean-DozdtbNi.cjs.map +1 -0
- package/dist/assertIsString-Bvk7bUL7.cjs +26 -0
- package/dist/assertIsString-Bvk7bUL7.cjs.map +1 -0
- package/dist/assertIsString-DqV9NwbI.js +20 -0
- package/dist/assertIsString-DqV9NwbI.js.map +1 -0
- package/dist/assertions/index.cjs +37 -40
- package/dist/assertions/index.cjs.map +1 -0
- package/dist/assertions/index.d.cts +12 -0
- package/dist/assertions/index.d.ts +10 -824
- package/dist/assertions/index.js +30 -13
- package/dist/assertions/index.js.map +1 -0
- package/dist/conversions/index.cjs +34 -103
- package/dist/conversions/index.d.cts +12 -0
- package/dist/conversions/index.d.ts +10 -1791
- package/dist/conversions/index.js +14 -24
- package/dist/conversions-CBs8-REq.cjs +448 -0
- package/dist/conversions-CBs8-REq.cjs.map +1 -0
- package/dist/conversions-EMJa3g-D.js +382 -0
- package/dist/conversions-EMJa3g-D.js.map +1 -0
- package/dist/events/index.cjs +55 -31
- package/dist/events/index.cjs.map +1 -0
- package/dist/events/index.d.cts +174 -0
- package/dist/events/index.d.ts +31 -35
- package/dist/events/index.js +50 -12
- package/dist/events/index.js.map +1 -0
- package/dist/formatEnvPort-DpIXzPAZ.js +159 -0
- package/dist/formatEnvPort-DpIXzPAZ.js.map +1 -0
- package/dist/formatEnvPort-hHNvOim-.cjs +171 -0
- package/dist/formatEnvPort-hHNvOim-.cjs.map +1 -0
- package/dist/formatters/index.cjs +21 -61
- package/dist/formatters/index.d.cts +12 -0
- package/dist/formatters/index.d.ts +10 -2152
- package/dist/formatters/index.js +10 -18
- package/dist/formatters-QcZO_Cpx.js +367 -0
- package/dist/formatters-QcZO_Cpx.js.map +1 -0
- package/dist/formatters-lAYgA11L.cjs +427 -0
- package/dist/formatters-lAYgA11L.cjs.map +1 -0
- package/dist/generators/index.cjs +161 -41
- package/dist/generators/index.cjs.map +1 -0
- package/dist/generators/index.d.cts +12 -0
- package/dist/generators/index.d.ts +10 -338
- package/dist/generators/index.js +154 -14
- package/dist/generators/index.js.map +1 -0
- package/dist/index-26W7ItWx.d.ts +760 -0
- package/dist/index-BPPQjAfs.d.cts +2359 -0
- package/dist/index-BXjlgBLz.d.cts +2139 -0
- package/dist/index-B_Wwo91H.d.ts +2359 -0
- package/dist/index-CpufydcI.d.cts +704 -0
- package/dist/index-Czc4O526.d.ts +333 -0
- package/dist/index-DPs1_p5G.d.cts +760 -0
- package/dist/index-DRpOyBSC.d.ts +1703 -0
- package/dist/index-DWWvtHUn.d.cts +822 -0
- package/dist/index-DnM0LD0n.d.cts +333 -0
- package/dist/index-GUZ9fK6T.d.ts +2139 -0
- package/dist/index-I4fAzwXV.d.ts +704 -0
- package/dist/index-JDrOl_19.d.ts +822 -0
- package/dist/index-b66P49Qe.d.cts +1703 -0
- package/dist/isBigInt-B1cijjqm.cjs +20 -0
- package/dist/isBigInt-B1cijjqm.cjs.map +1 -0
- package/dist/isBigInt-C0bN0Rhu.js +14 -0
- package/dist/isBigInt-C0bN0Rhu.js.map +1 -0
- package/dist/isEmptyObject-DI42NEo0.cjs +37 -0
- package/dist/isEmptyObject-DI42NEo0.cjs.map +1 -0
- package/dist/isEmptyObject-DeLVIJpl.js +25 -0
- package/dist/isEmptyObject-DeLVIJpl.js.map +1 -0
- package/dist/isEmptyString-BTUWYTbw.js +15 -0
- package/dist/isEmptyString-BTUWYTbw.js.map +1 -0
- package/dist/isEmptyString-CCK3bP74.cjs +21 -0
- package/dist/isEmptyString-CCK3bP74.cjs.map +1 -0
- package/dist/isEmptyValue-DMSMFTU8.cjs +30 -0
- package/dist/isEmptyValue-DMSMFTU8.cjs.map +1 -0
- package/dist/isEmptyValue-fjnfQnt5.js +24 -0
- package/dist/isEmptyValue-fjnfQnt5.js.map +1 -0
- package/dist/isEqual-B1fRgEuU.cjs +111 -0
- package/dist/isEqual-B1fRgEuU.cjs.map +1 -0
- package/dist/isEqual-DhyP8fB_.js +87 -0
- package/dist/isEqual-DhyP8fB_.js.map +1 -0
- package/dist/isFinite-BYMOo0os.js +15 -0
- package/dist/isFinite-BYMOo0os.js.map +1 -0
- package/dist/isFinite-sFkps2TY.cjs +21 -0
- package/dist/isFinite-sFkps2TY.cjs.map +1 -0
- package/dist/isInteger-DS9V7l_f.js +14 -0
- package/dist/isInteger-DS9V7l_f.js.map +1 -0
- package/dist/isInteger-FTCthMre.cjs +20 -0
- package/dist/isInteger-FTCthMre.cjs.map +1 -0
- package/dist/isPlainObject-DcFGh3_5.d.ts +530 -0
- package/dist/isPlainObject-doTI11Ib.d.cts +530 -0
- package/dist/isServer-D1TXfOs3.js +14 -0
- package/dist/isServer-D1TXfOs3.js.map +1 -0
- package/dist/isServer-q-QLFCqE.cjs +20 -0
- package/dist/isServer-q-QLFCqE.cjs.map +1 -0
- package/dist/isTypedArray-47R0wdrc.js +31 -0
- package/dist/isTypedArray-47R0wdrc.js.map +1 -0
- package/dist/isTypedArray-DiCoqffZ.cjs +43 -0
- package/dist/isTypedArray-DiCoqffZ.cjs.map +1 -0
- package/dist/isURL-CQiowFq2.js +14 -0
- package/dist/isURL-CQiowFq2.js.map +1 -0
- package/dist/isURL-WZypXsax.cjs +20 -0
- package/dist/isURL-WZypXsax.cjs.map +1 -0
- package/dist/isValidDomain-BSXshgkC.cjs +1788 -0
- package/dist/isValidDomain-BSXshgkC.cjs.map +1 -0
- package/dist/isValidDomain-DwA2EN79.js +1782 -0
- package/dist/isValidDomain-DwA2EN79.js.map +1 -0
- package/dist/next/index.cjs +119 -212
- package/dist/next/index.cjs.map +1 -0
- package/dist/next/index.d.cts +226 -0
- package/dist/next/index.d.ts +26 -31
- package/dist/next/index.js +117 -210
- package/dist/next/index.js.map +1 -0
- package/dist/next/server/index.cjs +25 -40
- package/dist/next/server/index.cjs.map +1 -0
- package/dist/next/server/index.d.cts +39 -0
- package/dist/next/server/index.d.ts +9 -10
- package/dist/next/server/index.js +23 -38
- package/dist/next/server/index.js.map +1 -0
- package/dist/noop-B2mTBhW-.cjs +18 -0
- package/dist/noop-B2mTBhW-.cjs.map +1 -0
- package/dist/noop-BzktGBVz.js +12 -0
- package/dist/noop-BzktGBVz.js.map +1 -0
- package/dist/normalizeSpaces-DQHR3Tlr.cjs +29 -0
- package/dist/normalizeSpaces-DQHR3Tlr.cjs.map +1 -0
- package/dist/normalizeSpaces-WS_iERJk.js +23 -0
- package/dist/normalizeSpaces-WS_iERJk.js.map +1 -0
- package/dist/normalizeString-2WLth_Gj.js +15 -0
- package/dist/normalizeString-2WLth_Gj.js.map +1 -0
- package/dist/normalizeString-D8euBcRD.cjs +21 -0
- package/dist/normalizeString-D8euBcRD.cjs.map +1 -0
- package/dist/operations/index.cjs +65 -32
- package/dist/operations/index.cjs.map +1 -0
- package/dist/operations/index.d.cts +139 -0
- package/dist/operations/index.d.ts +10 -15
- package/dist/operations/index.js +61 -17
- package/dist/operations/index.js.map +1 -0
- package/dist/parsers/index.cjs +12 -19
- package/dist/parsers/index.d.cts +239 -0
- package/dist/parsers/index.d.ts +71 -72
- package/dist/parsers/index.js +10 -12
- package/dist/parsers-DXtpsDyj.cjs +649 -0
- package/dist/parsers-DXtpsDyj.cjs.map +1 -0
- package/dist/parsers-Dpuq-V4u.js +643 -0
- package/dist/parsers-Dpuq-V4u.js.map +1 -0
- package/dist/parsing-B43x1sxn.js +50 -0
- package/dist/parsing-B43x1sxn.js.map +1 -0
- package/dist/parsing-lRoxn1Nz.cjs +56 -0
- package/dist/parsing-lRoxn1Nz.cjs.map +1 -0
- package/dist/predicates/index.cjs +91 -296
- package/dist/predicates/index.d.cts +13 -0
- package/dist/predicates/index.d.ts +12 -2482
- package/dist/predicates/index.js +23 -25
- package/dist/predicates-DiaYA7Ps.cjs +413 -0
- package/dist/predicates-DiaYA7Ps.cjs.map +1 -0
- package/dist/predicates-gNepszvo.js +257 -0
- package/dist/predicates-gNepszvo.js.map +1 -0
- package/dist/promises/index.cjs +76 -24
- package/dist/promises/index.cjs.map +1 -0
- package/dist/promises/index.d.cts +123 -0
- package/dist/promises/index.d.ts +28 -31
- package/dist/promises/index.js +73 -13
- package/dist/promises/index.js.map +1 -0
- package/dist/punyCode-CTWXVVFo.cjs +185 -0
- package/dist/punyCode-CTWXVVFo.cjs.map +1 -0
- package/dist/punyCode-hmiFzLWT.js +179 -0
- package/dist/punyCode-hmiFzLWT.js.map +1 -0
- package/dist/removeSpaces-BE8lfh-4.js +19 -0
- package/dist/removeSpaces-BE8lfh-4.js.map +1 -0
- package/dist/removeSpaces-DRRxNWlb.cjs +25 -0
- package/dist/removeSpaces-DRRxNWlb.cjs.map +1 -0
- package/dist/safeJsonParse-BBnQElk8.cjs +208 -0
- package/dist/safeJsonParse-BBnQElk8.cjs.map +1 -0
- package/dist/safeJsonParse-CXruaP0p.js +184 -0
- package/dist/safeJsonParse-CXruaP0p.js.map +1 -0
- package/dist/safeStableStringify-BNh3D0K0.js +88 -0
- package/dist/safeStableStringify-BNh3D0K0.js.map +1 -0
- package/dist/safeStableStringify-Cc62pfRp.cjs +106 -0
- package/dist/safeStableStringify-Cc62pfRp.cjs.map +1 -0
- package/dist/strings/index.cjs +76 -81
- package/dist/strings/index.cjs.map +1 -0
- package/dist/strings/index.d.cts +12 -0
- package/dist/strings/index.d.ts +10 -775
- package/dist/strings/index.js +59 -14
- package/dist/strings/index.js.map +1 -0
- package/dist/tailwind/index.cjs +19 -47
- package/dist/tailwind/index.d.cts +12 -0
- package/dist/tailwind/index.d.ts +11 -712
- package/dist/tailwind/index.js +10 -12
- package/dist/tailwind-DJ4cmLUw.cjs +247 -0
- package/dist/tailwind-DJ4cmLUw.cjs.map +1 -0
- package/dist/tailwind-IJvOdkZp.js +199 -0
- package/dist/tailwind-IJvOdkZp.js.map +1 -0
- package/dist/toStringArrayUnRecursive-CFs0jTEg.js +39 -0
- package/dist/toStringArrayUnRecursive-CFs0jTEg.js.map +1 -0
- package/dist/toStringArrayUnRecursive-xUaU8Ot9.cjs +51 -0
- package/dist/toStringArrayUnRecursive-xUaU8Ot9.cjs.map +1 -0
- package/dist/urls/index.cjs +129 -57
- package/dist/urls/index.cjs.map +1 -0
- package/dist/urls/index.d.cts +740 -0
- package/dist/urls/index.d.ts +218 -224
- package/dist/urls/index.js +121 -26
- package/dist/urls/index.js.map +1 -0
- package/package.json +203 -194
- package/dist/chunk-22V4WP3H.js +0 -53
- package/dist/chunk-2XSZ2ANI.js +0 -63
- package/dist/chunk-3T6VSWYX.js +0 -21
- package/dist/chunk-5WIEDF2J.js +0 -1823
- package/dist/chunk-6EDFZJZ5.cjs +0 -598
- package/dist/chunk-6LXWT2I5.js +0 -32
- package/dist/chunk-6YGBRENU.js +0 -209
- package/dist/chunk-7FGNVDEV.cjs +0 -38
- package/dist/chunk-AXDYWO67.js +0 -119
- package/dist/chunk-B6PMNZ4M.cjs +0 -35
- package/dist/chunk-BAV5T2E3.cjs +0 -15
- package/dist/chunk-BLF7SD66.js +0 -95
- package/dist/chunk-BMZZXZJ2.cjs +0 -30
- package/dist/chunk-BOYP3ARU.js +0 -264
- package/dist/chunk-BPYW5YL7.js +0 -16
- package/dist/chunk-C2PV3VWC.cjs +0 -118
- package/dist/chunk-CCJ2MSN7.js +0 -16
- package/dist/chunk-DAPAK2W3.cjs +0 -123
- package/dist/chunk-DLS3G6WQ.cjs +0 -23
- package/dist/chunk-DNMCR5JH.js +0 -370
- package/dist/chunk-DVMHRLKP.cjs +0 -16
- package/dist/chunk-EBYFYZW4.cjs +0 -26
- package/dist/chunk-ENMRZ4BE.js +0 -302
- package/dist/chunk-FJ4BQFVO.js +0 -587
- package/dist/chunk-GIKL4PUF.cjs +0 -106
- package/dist/chunk-GOFINGT6.js +0 -35
- package/dist/chunk-GXKQ3LHF.js +0 -101
- package/dist/chunk-HNBRGN4R.js +0 -24
- package/dist/chunk-HYN6FC5A.cjs +0 -249
- package/dist/chunk-IZGVBYFN.js +0 -242
- package/dist/chunk-JIE447J5.js +0 -676
- package/dist/chunk-JXEIJM5M.cjs +0 -237
- package/dist/chunk-K47GZDBH.js +0 -115
- package/dist/chunk-K5536YHG.cjs +0 -269
- package/dist/chunk-KHO2SBNA.cjs +0 -16
- package/dist/chunk-KXJ7X325.cjs +0 -308
- package/dist/chunk-L5RDAVVH.js +0 -14
- package/dist/chunk-LJHPTLWB.js +0 -109
- package/dist/chunk-M7ELWZXM.cjs +0 -1825
- package/dist/chunk-MSUW5VHZ.js +0 -1590
- package/dist/chunk-MUHRPRR7.cjs +0 -65
- package/dist/chunk-MV3TSQSH.cjs +0 -397
- package/dist/chunk-NLZLXWAU.cjs +0 -678
- package/dist/chunk-NVRZPF5M.cjs +0 -18
- package/dist/chunk-ONZFBJVW.js +0 -14
- package/dist/chunk-PGNL7JXO.cjs +0 -251
- package/dist/chunk-Q4GEQS7X.cjs +0 -564
- package/dist/chunk-QNKGP5DY.js +0 -14
- package/dist/chunk-QYI2VJLS.cjs +0 -211
- package/dist/chunk-RBWZII5I.js +0 -59
- package/dist/chunk-RMP7VMPB.cjs +0 -33
- package/dist/chunk-RZOGBYIS.js +0 -21
- package/dist/chunk-SU3UELUB.cjs +0 -36
- package/dist/chunk-SYHPSOUU.cjs +0 -1626
- package/dist/chunk-SZUNAEMR.js +0 -246
- package/dist/chunk-TER22LO4.cjs +0 -64
- package/dist/chunk-TJHGRQ4P.js +0 -33
- package/dist/chunk-U23I7JPB.cjs +0 -56
- package/dist/chunk-U7HHN47R.js +0 -552
- package/dist/chunk-UDA26MCU.cjs +0 -16
- package/dist/chunk-UIAWUZ4H.js +0 -31
- package/dist/chunk-ULQPCIA2.js +0 -16
- package/dist/chunk-VJDDGRIK.cjs +0 -16
- package/dist/chunk-WETQI6HM.js +0 -232
- package/dist/chunk-WLOQQFDS.cjs +0 -18
- package/dist/chunk-WVSPXFTY.js +0 -14
- package/dist/chunk-WXFTVXBF.cjs +0 -23
- package/dist/chunk-XPVTIGU2.cjs +0 -113
- package/dist/chunk-XX6RUGTM.cjs +0 -18
- package/dist/chunk-YWHHVDT4.js +0 -13
- package/dist/chunk-ZPDMWDGZ.cjs +0 -101
- package/dist/chunk-ZVWZEGQP.js +0 -28
- package/dist/index.d.ts +0 -24
- package/dist/isPlainObject-0p3VveWr.d.ts +0 -534
- package/dist/rzl-utils.global.js +0 -10
package/dist/chunk-BOYP3ARU.js
DELETED
|
@@ -1,264 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* ====================================================
|
|
3
|
-
* Rzl Utils-JS.
|
|
4
|
-
* ----------------------------------------------------
|
|
5
|
-
* Version: 3.11.1.
|
|
6
|
-
* Author: Rizalvin Dwiky.
|
|
7
|
-
* Repository: https://github.com/rzl-zone/utils-js.
|
|
8
|
-
* ====================================================
|
|
9
|
-
*/
|
|
10
|
-
import { isEmptyArray, isEmptyObject } from './chunk-GOFINGT6.js';
|
|
11
|
-
import { noop } from './chunk-YWHHVDT4.js';
|
|
12
|
-
import { safeStableStringify } from './chunk-AXDYWO67.js';
|
|
13
|
-
import { isNonEmptyString, getPreciseType, isNull, isUndefined, isString, isArray, isObject, isNumber, isNaN as isNaN$1, isError, assertIsPlainObject, hasOwnProp, isBoolean, isFunction } from './chunk-MSUW5VHZ.js';
|
|
14
|
-
|
|
15
|
-
var parseCustomDate = (dateString, format) => {
|
|
16
|
-
if (!isNonEmptyString(dateString) || !isNonEmptyString(format)) {
|
|
17
|
-
throw new TypeError(
|
|
18
|
-
`Parameter \`dateString\` and \`format\` must be of type \`string\` and not empty-string, but received: "['dateString': \`${getPreciseType(
|
|
19
|
-
dateString
|
|
20
|
-
)}\` - (current value: \`${safeStableStringify(dateString, {
|
|
21
|
-
keepUndefined: true
|
|
22
|
-
})}\`), 'format': \`${getPreciseType(
|
|
23
|
-
format
|
|
24
|
-
)}\` - (current value: \`${safeStableStringify(format, {
|
|
25
|
-
keepUndefined: true
|
|
26
|
-
})}\`)]".`
|
|
27
|
-
);
|
|
28
|
-
}
|
|
29
|
-
const dateParts = dateString.split(/[-/]/).map(Number);
|
|
30
|
-
if (dateParts.length !== 3 || dateParts.some(isNaN)) return null;
|
|
31
|
-
let day, month, year;
|
|
32
|
-
if (format === "DD/MM/YYYY") {
|
|
33
|
-
[day, month, year] = dateParts;
|
|
34
|
-
} else if (format === "MM/DD/YYYY") {
|
|
35
|
-
[month, day, year] = dateParts;
|
|
36
|
-
} else {
|
|
37
|
-
return null;
|
|
38
|
-
}
|
|
39
|
-
month -= 1;
|
|
40
|
-
const date = new Date(year, month, day);
|
|
41
|
-
if (date.getFullYear() !== year || date.getMonth() !== month || date.getDate() !== day) {
|
|
42
|
-
return null;
|
|
43
|
-
}
|
|
44
|
-
return date;
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
var validateJsonParsingOptions = (optionsValue = {}) => {
|
|
48
|
-
assertIsPlainObject(optionsValue, {
|
|
49
|
-
message: ({ currentType, validType }) => `Second parameter (\`options\`) must be of type \`${validType}\`, but received: \`${currentType}\`.`
|
|
50
|
-
});
|
|
51
|
-
const convertBooleans = hasOwnProp(optionsValue, "convertBooleans") ? optionsValue.convertBooleans : false;
|
|
52
|
-
const convertDates = hasOwnProp(optionsValue, "convertDates") ? optionsValue.convertDates : false;
|
|
53
|
-
const convertNumbers = hasOwnProp(optionsValue, "convertNumbers") ? optionsValue.convertNumbers : false;
|
|
54
|
-
const loggingOnFail = hasOwnProp(optionsValue, "loggingOnFail") ? optionsValue.loggingOnFail : false;
|
|
55
|
-
const removeEmptyArrays = hasOwnProp(optionsValue, "removeEmptyArrays") ? optionsValue.removeEmptyArrays : false;
|
|
56
|
-
const removeEmptyObjects = hasOwnProp(optionsValue, "removeEmptyObjects") ? optionsValue.removeEmptyObjects : false;
|
|
57
|
-
const removeNulls = hasOwnProp(optionsValue, "removeNulls") ? optionsValue.removeNulls : false;
|
|
58
|
-
const removeUndefined = hasOwnProp(optionsValue, "removeUndefined") ? optionsValue.removeUndefined : false;
|
|
59
|
-
const strictMode = hasOwnProp(optionsValue, "strictMode") ? optionsValue.strictMode : false;
|
|
60
|
-
const checkSymbols = hasOwnProp(optionsValue, "checkSymbols") ? optionsValue.checkSymbols : false;
|
|
61
|
-
const convertNaN = hasOwnProp(optionsValue, "convertNaN") ? optionsValue.convertNaN : false;
|
|
62
|
-
const customDateFormats = hasOwnProp(optionsValue, "customDateFormats") ? optionsValue.customDateFormats : [];
|
|
63
|
-
const onError = hasOwnProp(optionsValue, "onError") ? optionsValue.onError : noop;
|
|
64
|
-
if (!(isBoolean(convertBooleans) && isBoolean(convertDates) && isBoolean(convertNumbers) && isBoolean(convertNaN) && isBoolean(checkSymbols) && isBoolean(loggingOnFail) && isBoolean(removeEmptyArrays) && isBoolean(removeEmptyObjects) && isBoolean(removeNulls) && isBoolean(removeUndefined) && isBoolean(strictMode) && isArray(customDateFormats) && isFunction(onError))) {
|
|
65
|
-
throw new TypeError(
|
|
66
|
-
`Invalid \`options\` parameter (second argument): \`convertBooleans\`, \`convertDates\`, \`convertNumbers\`, \`loggingOnFail\`, \`removeEmptyArrays\`, \`removeEmptyObjects\`, \`removeNulls\`, \`removeUndefined\`, \`strictMode\` expected to be a \`boolean\` type, \`customDateFormats\` expected to be a \`array\` type and \`onError\` expected to be a \`void function\` type. But received: ['convertBooleans': \`${getPreciseType(
|
|
67
|
-
convertBooleans
|
|
68
|
-
)}\`, 'convertDates': \`${getPreciseType(
|
|
69
|
-
convertDates
|
|
70
|
-
)}\`, 'convertNumbers': \`${getPreciseType(
|
|
71
|
-
convertNumbers
|
|
72
|
-
)}\`, 'loggingOnFail': \`${getPreciseType(
|
|
73
|
-
loggingOnFail
|
|
74
|
-
)}\`, 'removeEmptyArrays': \`${getPreciseType(
|
|
75
|
-
removeEmptyArrays
|
|
76
|
-
)}\`, 'removeEmptyObjects': \`${getPreciseType(
|
|
77
|
-
removeEmptyObjects
|
|
78
|
-
)}\`, 'removeNulls': \`${getPreciseType(
|
|
79
|
-
removeNulls
|
|
80
|
-
)}\`, 'removeUndefined': \`${getPreciseType(
|
|
81
|
-
removeUndefined
|
|
82
|
-
)}\`, 'strictMode': \`${getPreciseType(
|
|
83
|
-
strictMode
|
|
84
|
-
)}\`, 'customDateFormats': \`${getPreciseType(
|
|
85
|
-
customDateFormats
|
|
86
|
-
)}\`, 'onError': \`${getPreciseType(onError)}\`].`
|
|
87
|
-
);
|
|
88
|
-
}
|
|
89
|
-
return {
|
|
90
|
-
convertBooleans,
|
|
91
|
-
convertDates,
|
|
92
|
-
convertNumbers,
|
|
93
|
-
convertNaN,
|
|
94
|
-
loggingOnFail,
|
|
95
|
-
removeEmptyArrays,
|
|
96
|
-
removeEmptyObjects,
|
|
97
|
-
removeNulls,
|
|
98
|
-
removeUndefined,
|
|
99
|
-
strictMode,
|
|
100
|
-
customDateFormats,
|
|
101
|
-
onError,
|
|
102
|
-
checkSymbols
|
|
103
|
-
};
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
var cleanParsedData = (data, options = {}) => {
|
|
107
|
-
const validOptions = validateJsonParsingOptions(options);
|
|
108
|
-
if (isNull(data)) return validOptions.removeNulls ? void 0 : null;
|
|
109
|
-
if (isUndefined(data)) return validOptions.removeUndefined ? void 0 : void 0;
|
|
110
|
-
if (isString(data)) {
|
|
111
|
-
const trimmed = data.trim();
|
|
112
|
-
if (validOptions.convertNaN && trimmed === "NaN") return NaN;
|
|
113
|
-
if (validOptions.convertNumbers && !isNaN(Number(trimmed))) {
|
|
114
|
-
return Number(trimmed);
|
|
115
|
-
}
|
|
116
|
-
if (validOptions.convertBooleans) {
|
|
117
|
-
if (trimmed === "true") return true;
|
|
118
|
-
if (trimmed === "false") return false;
|
|
119
|
-
}
|
|
120
|
-
if (validOptions.convertDates) {
|
|
121
|
-
if (/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/.test(trimmed)) {
|
|
122
|
-
return new Date(trimmed);
|
|
123
|
-
}
|
|
124
|
-
if (validOptions.customDateFormats?.length) {
|
|
125
|
-
for (const format of validOptions.customDateFormats) {
|
|
126
|
-
const date = parseCustomDate(trimmed, format);
|
|
127
|
-
if (date) return date;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
return validOptions.strictMode ? void 0 : trimmed;
|
|
132
|
-
}
|
|
133
|
-
if (isArray(data)) {
|
|
134
|
-
const cleanedArray = data.map((item) => cleanParsedData(item, validOptions)).filter((item) => !isUndefined(item));
|
|
135
|
-
return validOptions.removeEmptyArrays && isEmptyArray(cleanedArray) ? void 0 : cleanedArray;
|
|
136
|
-
}
|
|
137
|
-
if (isObject(data)) {
|
|
138
|
-
const cleanedObject = {};
|
|
139
|
-
for (const key in data) {
|
|
140
|
-
if (Object.prototype.hasOwnProperty.call(data, key)) {
|
|
141
|
-
const cleanedValue = cleanParsedData(data[key], validOptions);
|
|
142
|
-
if (!isUndefined(cleanedValue)) {
|
|
143
|
-
cleanedObject[key] = cleanedValue;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
return validOptions.removeEmptyObjects && isEmptyObject(cleanedObject, { checkSymbols: validOptions.checkSymbols }) ? void 0 : cleanedObject;
|
|
148
|
-
}
|
|
149
|
-
return validOptions.strictMode ? void 0 : data;
|
|
150
|
-
};
|
|
151
|
-
|
|
152
|
-
var extractDigits = (value) => {
|
|
153
|
-
if (!isString(value) && !isNumber(value)) return 0;
|
|
154
|
-
const cleaned = String(value).trim().replace(/[^0-9]/g, "");
|
|
155
|
-
return Number(cleaned) || 0;
|
|
156
|
-
};
|
|
157
|
-
|
|
158
|
-
function fixSingleQuotesEscapeBackslash(input) {
|
|
159
|
-
const validEscapes = /* @__PURE__ */ new Set(["\\", '"', "/", "b", "f", "n", "r", "t", "u"]);
|
|
160
|
-
let output = "";
|
|
161
|
-
let inSingleQuote = false;
|
|
162
|
-
let inDoubleQuote = false;
|
|
163
|
-
let escapeNext = false;
|
|
164
|
-
for (let i = 0; i < input.length; i++) {
|
|
165
|
-
const c = input[i];
|
|
166
|
-
if (escapeNext) {
|
|
167
|
-
if (inSingleQuote) {
|
|
168
|
-
if (c === "'") {
|
|
169
|
-
output += "'";
|
|
170
|
-
} else if (validEscapes.has(c)) {
|
|
171
|
-
if (c === "\\") {
|
|
172
|
-
output += "\\\\";
|
|
173
|
-
} else if (c === '"') {
|
|
174
|
-
output += '\\"';
|
|
175
|
-
} else {
|
|
176
|
-
output += "\\" + c;
|
|
177
|
-
}
|
|
178
|
-
} else {
|
|
179
|
-
output += "\\\\" + c;
|
|
180
|
-
}
|
|
181
|
-
} else if (inDoubleQuote) {
|
|
182
|
-
if (c === '"') {
|
|
183
|
-
output += '\\"';
|
|
184
|
-
} else if (validEscapes.has(c)) {
|
|
185
|
-
output += "\\" + c;
|
|
186
|
-
} else {
|
|
187
|
-
output += "\\\\" + c;
|
|
188
|
-
}
|
|
189
|
-
} else {
|
|
190
|
-
output += "\\" + c;
|
|
191
|
-
}
|
|
192
|
-
escapeNext = false;
|
|
193
|
-
continue;
|
|
194
|
-
}
|
|
195
|
-
if (c === "\\") {
|
|
196
|
-
escapeNext = true;
|
|
197
|
-
continue;
|
|
198
|
-
}
|
|
199
|
-
if (!inSingleQuote && !inDoubleQuote) {
|
|
200
|
-
if (c === "'") {
|
|
201
|
-
output += '"';
|
|
202
|
-
inSingleQuote = true;
|
|
203
|
-
continue;
|
|
204
|
-
}
|
|
205
|
-
if (c === '"') {
|
|
206
|
-
output += '"';
|
|
207
|
-
inDoubleQuote = true;
|
|
208
|
-
continue;
|
|
209
|
-
}
|
|
210
|
-
} else if (inSingleQuote) {
|
|
211
|
-
if (c === "'") {
|
|
212
|
-
output += '"';
|
|
213
|
-
inSingleQuote = false;
|
|
214
|
-
continue;
|
|
215
|
-
}
|
|
216
|
-
} else if (inDoubleQuote) {
|
|
217
|
-
if (c === '"') {
|
|
218
|
-
output += '"';
|
|
219
|
-
inDoubleQuote = false;
|
|
220
|
-
continue;
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
output += c;
|
|
224
|
-
}
|
|
225
|
-
return output;
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
function safeJsonParse(value, options = {}) {
|
|
229
|
-
if (isNull(value)) return null;
|
|
230
|
-
const validOptions = validateJsonParsingOptions(options);
|
|
231
|
-
if (validOptions.convertNaN && (isNaN$1(value) || isNonEmptyString(value) && value === "NaN")) {
|
|
232
|
-
return NaN;
|
|
233
|
-
}
|
|
234
|
-
if (validOptions.convertNumbers && !isNaN$1(Number(value)) && isNumber(extractDigits(value))) {
|
|
235
|
-
return Number(value);
|
|
236
|
-
}
|
|
237
|
-
if (!isString(value)) return void 0;
|
|
238
|
-
try {
|
|
239
|
-
let normalized = fixSingleQuotesEscapeBackslash(value);
|
|
240
|
-
if (validOptions.removeUndefined) {
|
|
241
|
-
normalized = normalized.replace(/,\s*"[^"]*"\s*:\s*undefined(?=\s*[},])/g, "").replace(/"[^"]*"\s*:\s*undefined\s*(,)?/g, "");
|
|
242
|
-
} else {
|
|
243
|
-
normalized = normalized.replace(/:\s*undefined(?=\s*[,}])/g, ":null");
|
|
244
|
-
}
|
|
245
|
-
if (validOptions.convertNaN) {
|
|
246
|
-
normalized = normalized.replace(/:\s*NaN(?=\s*[,}])/g, ':"NaN"');
|
|
247
|
-
} else {
|
|
248
|
-
normalized = normalized.replace(/:\s*NaN(?=\s*[,}])/g, ':"NaN"').replace(/,\s*"[^"]*"\s*:\s*NaN(?=\s*[},])/g, "").replace(/"[^"]*"\s*:\s*NaN\s*(,)?/g, "");
|
|
249
|
-
}
|
|
250
|
-
normalized = normalized.replace(/,(\s*[}\]])/g, "$1");
|
|
251
|
-
const parsed = JSON.parse(normalized);
|
|
252
|
-
return cleanParsedData(parsed, validOptions);
|
|
253
|
-
} catch (error) {
|
|
254
|
-
if (validOptions.loggingOnFail) {
|
|
255
|
-
console.error("Failed to parsing at `safeJsonParse`:", error);
|
|
256
|
-
}
|
|
257
|
-
validOptions.onError(
|
|
258
|
-
isError(error) ? new Error(error.message.replace(/^JSON\.parse:/, "Failed to parsing")) : new Error(String(error))
|
|
259
|
-
);
|
|
260
|
-
return void 0;
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
export { cleanParsedData, extractDigits, parseCustomDate, safeJsonParse };
|
package/dist/chunk-BPYW5YL7.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* ====================================================
|
|
3
|
-
* Rzl Utils-JS.
|
|
4
|
-
* ----------------------------------------------------
|
|
5
|
-
* Version: 3.11.1.
|
|
6
|
-
* Author: Rizalvin Dwiky.
|
|
7
|
-
* Repository: https://github.com/rzl-zone/utils-js.
|
|
8
|
-
* ====================================================
|
|
9
|
-
*/
|
|
10
|
-
import { isNonEmptyString } from './chunk-MSUW5VHZ.js';
|
|
11
|
-
|
|
12
|
-
var normalizeString = (input) => {
|
|
13
|
-
return isNonEmptyString(input) ? input.trim() : "";
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export { normalizeString };
|
package/dist/chunk-C2PV3VWC.cjs
DELETED
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* ====================================================
|
|
3
|
-
* Rzl Utils-JS.
|
|
4
|
-
* ----------------------------------------------------
|
|
5
|
-
* Version: 3.11.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 chunkDAPAK2W3_cjs = require('./chunk-DAPAK2W3.cjs');
|
|
14
|
-
var chunkSYHPSOUU_cjs = require('./chunk-SYHPSOUU.cjs');
|
|
15
|
-
|
|
16
|
-
var CustomPromise = class extends Promise {
|
|
17
|
-
_value;
|
|
18
|
-
_error;
|
|
19
|
-
_finish = [];
|
|
20
|
-
constructor(executor) {
|
|
21
|
-
let resolveOuter;
|
|
22
|
-
let rejectOuter;
|
|
23
|
-
super((resolve, reject) => {
|
|
24
|
-
resolveOuter = resolve;
|
|
25
|
-
rejectOuter = reject;
|
|
26
|
-
});
|
|
27
|
-
executor(
|
|
28
|
-
(v) => {
|
|
29
|
-
this._value = v;
|
|
30
|
-
resolveOuter(v);
|
|
31
|
-
this._finish.forEach((f) => f(v, void 0));
|
|
32
|
-
},
|
|
33
|
-
(e) => {
|
|
34
|
-
this._error = e;
|
|
35
|
-
rejectOuter(e);
|
|
36
|
-
this._finish.forEach((f) => f(void 0, e));
|
|
37
|
-
}
|
|
38
|
-
);
|
|
39
|
-
Object.setPrototypeOf(this, new.target.prototype);
|
|
40
|
-
}
|
|
41
|
-
then(onfulfilled, onrejected) {
|
|
42
|
-
return super.then(onfulfilled, onrejected);
|
|
43
|
-
}
|
|
44
|
-
catch(onrejected) {
|
|
45
|
-
return super.catch(onrejected);
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Registers a callback to be invoked **exactly once** when the
|
|
49
|
-
* promise settles, with access to both the resolved value and
|
|
50
|
-
* the rejection reason.
|
|
51
|
-
*
|
|
52
|
-
* If the promise is already settled when `finish` is called,
|
|
53
|
-
* the callback executes immediately on the same tick.
|
|
54
|
-
*
|
|
55
|
-
* @param cb Callback receiving the final `(value, error)`.
|
|
56
|
-
* @returns `this` for fluent chaining.
|
|
57
|
-
*/
|
|
58
|
-
finish(cb) {
|
|
59
|
-
if (this._value !== void 0 || this._error !== void 0) {
|
|
60
|
-
cb(this._value, this._error);
|
|
61
|
-
} else {
|
|
62
|
-
this._finish.push(cb);
|
|
63
|
-
}
|
|
64
|
-
return this;
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
var AbortError = class extends Error {
|
|
69
|
-
constructor(message = "The operation was aborted", name = "AbortError") {
|
|
70
|
-
super(message);
|
|
71
|
-
this.name = name;
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
var delay = (milliSeconds = 1e3, signal) => {
|
|
75
|
-
if (!chunkDVMHRLKP_cjs.isInteger(milliSeconds) || milliSeconds <= 0) {
|
|
76
|
-
throw new TypeError(
|
|
77
|
-
`First parameter (\`milliSeconds\`) must be of type \`number\` and value must be a \`non-zero\`, \`non-NaN\`, \`non-negative\`, and \`integer-number\`, but received: \`${chunkSYHPSOUU_cjs.getPreciseType(
|
|
78
|
-
milliSeconds
|
|
79
|
-
)}\`, with value: \`${chunkDAPAK2W3_cjs.safeStableStringify(milliSeconds, {
|
|
80
|
-
keepUndefined: true
|
|
81
|
-
})}\`.`
|
|
82
|
-
);
|
|
83
|
-
}
|
|
84
|
-
if (chunkSYHPSOUU_cjs.isNull(signal) || signal && !(signal instanceof AbortSignal)) {
|
|
85
|
-
throw new TypeError(
|
|
86
|
-
"Second parameter (`signal`) must be an `instance of AbortSignal` if provided."
|
|
87
|
-
);
|
|
88
|
-
}
|
|
89
|
-
return new Promise((resolve, reject) => {
|
|
90
|
-
const timer = setTimeout(() => {
|
|
91
|
-
cleanup();
|
|
92
|
-
resolve();
|
|
93
|
-
}, milliSeconds);
|
|
94
|
-
const cleanup = () => {
|
|
95
|
-
clearTimeout(timer);
|
|
96
|
-
if (signal) signal.removeEventListener("abort", onAbort);
|
|
97
|
-
};
|
|
98
|
-
const onAbort = () => {
|
|
99
|
-
cleanup();
|
|
100
|
-
reject(
|
|
101
|
-
new AbortError(
|
|
102
|
-
"Function `delay` from `@rzl-zone/utils-js` was aborted.",
|
|
103
|
-
"AbortError"
|
|
104
|
-
)
|
|
105
|
-
);
|
|
106
|
-
};
|
|
107
|
-
if (signal) {
|
|
108
|
-
if (signal.aborted) {
|
|
109
|
-
onAbort();
|
|
110
|
-
} else {
|
|
111
|
-
signal.addEventListener("abort", onAbort, { once: true });
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
exports.CustomPromise = CustomPromise;
|
|
118
|
-
exports.delay = delay;
|
package/dist/chunk-CCJ2MSN7.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* ====================================================
|
|
3
|
-
* Rzl Utils-JS.
|
|
4
|
-
* ----------------------------------------------------
|
|
5
|
-
* Version: 3.11.1.
|
|
6
|
-
* Author: Rizalvin Dwiky.
|
|
7
|
-
* Repository: https://github.com/rzl-zone/utils-js.
|
|
8
|
-
* ====================================================
|
|
9
|
-
*/
|
|
10
|
-
import { isNumber } from './chunk-MSUW5VHZ.js';
|
|
11
|
-
|
|
12
|
-
function isFinite(value) {
|
|
13
|
-
return isNumber(value) && Number.isFinite(value);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export { isFinite };
|
package/dist/chunk-DAPAK2W3.cjs
DELETED
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* ====================================================
|
|
3
|
-
* Rzl Utils-JS.
|
|
4
|
-
* ----------------------------------------------------
|
|
5
|
-
* Version: 3.11.1.
|
|
6
|
-
* Author: Rizalvin Dwiky.
|
|
7
|
-
* Repository: https://github.com/rzl-zone/utils-js.
|
|
8
|
-
* ====================================================
|
|
9
|
-
*/
|
|
10
|
-
'use strict';
|
|
11
|
-
|
|
12
|
-
var chunkUDA26MCU_cjs = require('./chunk-UDA26MCU.cjs');
|
|
13
|
-
var chunkSYHPSOUU_cjs = require('./chunk-SYHPSOUU.cjs');
|
|
14
|
-
|
|
15
|
-
function isMap(value) {
|
|
16
|
-
return Object.prototype.toString.call(value) === "[object Map]" || value instanceof Map;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
var isDate = (value, options = {}) => {
|
|
20
|
-
chunkSYHPSOUU_cjs.assertIsPlainObject(options, {
|
|
21
|
-
message: ({ currentType, validType }) => `Second parameter (\`options\`) must be of type \`${validType}\`, but received: \`${currentType}\`.`
|
|
22
|
-
});
|
|
23
|
-
const skipInvalidDate = chunkSYHPSOUU_cjs.isPlainObject(options) && chunkSYHPSOUU_cjs.isBoolean(options.skipInvalidDate) ? options.skipInvalidDate : false;
|
|
24
|
-
const instanceDate = value instanceof Date;
|
|
25
|
-
if (skipInvalidDate) return instanceDate;
|
|
26
|
-
return instanceDate && !chunkSYHPSOUU_cjs.isNaN(value.getTime());
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
var safeStableStringify = (value, options = {}) => {
|
|
30
|
-
chunkSYHPSOUU_cjs.assertIsPlainObject(options, {
|
|
31
|
-
message: ({ currentType, validType }) => `Second parameter (\`options\`) must be of type \`${validType}\`, but received: \`${currentType}\`.`
|
|
32
|
-
});
|
|
33
|
-
const pretty = chunkSYHPSOUU_cjs.hasOwnProp(options, "pretty") ? options.pretty : false;
|
|
34
|
-
const sortKeys = chunkSYHPSOUU_cjs.hasOwnProp(options, "sortKeys") ? options.sortKeys : true;
|
|
35
|
-
const sortArray = chunkSYHPSOUU_cjs.hasOwnProp(options, "sortArray") ? options.sortArray : false;
|
|
36
|
-
const keepUndefined = chunkSYHPSOUU_cjs.hasOwnProp(options, "keepUndefined") ? options.keepUndefined : false;
|
|
37
|
-
if (!chunkSYHPSOUU_cjs.isBoolean(sortKeys) || !chunkSYHPSOUU_cjs.isBoolean(sortArray) || !chunkSYHPSOUU_cjs.isBoolean(pretty) || !chunkSYHPSOUU_cjs.isBoolean(keepUndefined)) {
|
|
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': \`${chunkSYHPSOUU_cjs.getPreciseType(
|
|
40
|
-
sortKeys
|
|
41
|
-
)}\`, 'sortArray': \`${chunkSYHPSOUU_cjs.getPreciseType(
|
|
42
|
-
sortArray
|
|
43
|
-
)}\`, 'keepUndefined': \`${chunkSYHPSOUU_cjs.getPreciseType(
|
|
44
|
-
keepUndefined
|
|
45
|
-
)}\`, 'pretty': \`${chunkSYHPSOUU_cjs.getPreciseType(pretty)}\`]".`
|
|
46
|
-
);
|
|
47
|
-
}
|
|
48
|
-
if (chunkSYHPSOUU_cjs.isUndefined(value)) {
|
|
49
|
-
return keepUndefined ? "undefined" : "null";
|
|
50
|
-
}
|
|
51
|
-
const seen = /* @__PURE__ */ new WeakSet();
|
|
52
|
-
const isPrimitive = (val) => chunkSYHPSOUU_cjs.isNull(val) || !chunkSYHPSOUU_cjs.isObjectOrArray(val) && !chunkSYHPSOUU_cjs.isFunction(val);
|
|
53
|
-
const deepProcess = (val) => {
|
|
54
|
-
if (chunkSYHPSOUU_cjs.isNumberObject(val)) {
|
|
55
|
-
const valOf = val.valueOf();
|
|
56
|
-
return chunkSYHPSOUU_cjs.isNaN(valOf) || chunkSYHPSOUU_cjs.isInfinityNumber(valOf) ? null : valOf;
|
|
57
|
-
}
|
|
58
|
-
if (chunkSYHPSOUU_cjs.isStringObject(val)) return val.valueOf();
|
|
59
|
-
if (chunkSYHPSOUU_cjs.isBooleanObject(val)) return val.valueOf();
|
|
60
|
-
if (chunkSYHPSOUU_cjs.isFunction(val) || chunkSYHPSOUU_cjs.isSymbol(val)) return void 0;
|
|
61
|
-
if (chunkUDA26MCU_cjs.isBigInt(val)) return val.toString();
|
|
62
|
-
if (chunkSYHPSOUU_cjs.isNaN(val) || chunkSYHPSOUU_cjs.isInfinityNumber(val)) return null;
|
|
63
|
-
if (chunkSYHPSOUU_cjs.isUndefined(val)) {
|
|
64
|
-
return keepUndefined ? void 0 : null;
|
|
65
|
-
}
|
|
66
|
-
if (chunkSYHPSOUU_cjs.isObjectOrArray(val)) {
|
|
67
|
-
if (seen.has(val)) return "[Circular]";
|
|
68
|
-
seen.add(val);
|
|
69
|
-
if (isDate(val)) return val.toISOString();
|
|
70
|
-
if (isMap(val)) {
|
|
71
|
-
return {
|
|
72
|
-
map: Array.from(val.entries()).map(([k, v]) => [k, deepProcess(v)])
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
if (chunkSYHPSOUU_cjs.isSet(val)) return { set: Array.from(val.values()).map(deepProcess) };
|
|
76
|
-
if (chunkSYHPSOUU_cjs.isArray(val)) {
|
|
77
|
-
const processedArr = val.map(deepProcess);
|
|
78
|
-
if (sortArray) {
|
|
79
|
-
const primitives = [];
|
|
80
|
-
const nonPrimitives = [];
|
|
81
|
-
for (const item of processedArr) {
|
|
82
|
-
if (isPrimitive(item)) primitives.push(item);
|
|
83
|
-
else nonPrimitives.push(item);
|
|
84
|
-
}
|
|
85
|
-
primitives.sort((a, b) => {
|
|
86
|
-
if (chunkSYHPSOUU_cjs.isNumber(a) && chunkSYHPSOUU_cjs.isNumber(b)) return a - b;
|
|
87
|
-
return String(a).localeCompare(String(b));
|
|
88
|
-
});
|
|
89
|
-
return [...primitives, ...nonPrimitives];
|
|
90
|
-
}
|
|
91
|
-
return processedArr;
|
|
92
|
-
}
|
|
93
|
-
const keys = Object.keys(val);
|
|
94
|
-
if (sortKeys) {
|
|
95
|
-
keys.sort((a, b) => {
|
|
96
|
-
const na = Number(a);
|
|
97
|
-
const nb = Number(b);
|
|
98
|
-
if (!chunkSYHPSOUU_cjs.isNaN(na) && !chunkSYHPSOUU_cjs.isNaN(nb)) return na - nb;
|
|
99
|
-
return a.localeCompare(b);
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
const result = {};
|
|
103
|
-
if (chunkSYHPSOUU_cjs.isObject(val)) {
|
|
104
|
-
for (const k of keys) {
|
|
105
|
-
const v = deepProcess(val[k]);
|
|
106
|
-
if (!chunkSYHPSOUU_cjs.isUndefined(v)) result[k] = v;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
return result;
|
|
110
|
-
}
|
|
111
|
-
return val;
|
|
112
|
-
};
|
|
113
|
-
try {
|
|
114
|
-
return JSON.stringify(deepProcess(value), null, pretty ? 2 : 0);
|
|
115
|
-
} catch (err) {
|
|
116
|
-
console.warn("Error in safeStableStringify:", err);
|
|
117
|
-
return "{}";
|
|
118
|
-
}
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
exports.isDate = isDate;
|
|
122
|
-
exports.isMap = isMap;
|
|
123
|
-
exports.safeStableStringify = safeStableStringify;
|
package/dist/chunk-DLS3G6WQ.cjs
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* ====================================================
|
|
3
|
-
* Rzl Utils-JS.
|
|
4
|
-
* ----------------------------------------------------
|
|
5
|
-
* Version: 3.11.1.
|
|
6
|
-
* Author: Rizalvin Dwiky.
|
|
7
|
-
* Repository: https://github.com/rzl-zone/utils-js.
|
|
8
|
-
* ====================================================
|
|
9
|
-
*/
|
|
10
|
-
'use strict';
|
|
11
|
-
|
|
12
|
-
var chunkSYHPSOUU_cjs = require('./chunk-SYHPSOUU.cjs');
|
|
13
|
-
|
|
14
|
-
function assertIsArray(value, options) {
|
|
15
|
-
if (chunkSYHPSOUU_cjs.isArray(value)) return;
|
|
16
|
-
chunkSYHPSOUU_cjs.resolveErrorMessageAssertions({
|
|
17
|
-
value,
|
|
18
|
-
options,
|
|
19
|
-
requiredValidType: "array"
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
exports.assertIsArray = assertIsArray;
|