@rzl-zone/utils-js 3.13.1-beta.0 → 3.14.0-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/README.md +7 -6
- package/dist/.references/index.d.cts +2 -1
- package/dist/.references/index.d.ts +2 -1
- package/dist/AbortError-DK6kpzbu.cjs +26 -0
- package/dist/AbortError-DK6kpzbu.cjs.map +1 -0
- package/dist/AbortError-DVT8lAKn.js +20 -0
- package/dist/AbortError-DVT8lAKn.js.map +1 -0
- package/dist/{assertIsArray-DrLORH0Y.js → assertIsArray-CG7L7vlt.js} +3 -3
- package/dist/assertIsArray-CG7L7vlt.js.map +1 -0
- package/dist/{assertIsArray-CqIFmlgj.cjs → assertIsArray-CtCRD-_G.cjs} +5 -5
- package/dist/assertIsArray-CtCRD-_G.cjs.map +1 -0
- package/dist/assertIsPlainObject-DPZLj-Ho.cjs +26 -0
- package/dist/assertIsPlainObject-DPZLj-Ho.cjs.map +1 -0
- package/dist/assertIsPlainObject-j9bDqNLo.js +20 -0
- package/dist/assertIsPlainObject-j9bDqNLo.js.map +1 -0
- package/dist/{assertIsString-1iLqxrN0.js → assertIsString-CHIwE12y.js} +4 -4
- package/dist/assertIsString-CHIwE12y.js.map +1 -0
- package/dist/{assertIsString-DGDLC-XD.cjs → assertIsString-CjE9kbQ_.cjs} +6 -6
- package/dist/assertIsString-CjE9kbQ_.cjs.map +1 -0
- package/dist/assertions/index.cjs +14 -12
- package/dist/assertions/index.cjs.map +1 -1
- package/dist/assertions/index.d.cts +2 -2
- package/dist/assertions/index.d.ts +2 -2
- package/dist/assertions/index.js +10 -8
- package/dist/assertions/index.js.map +1 -1
- package/dist/conversions/index.cjs +6 -6
- package/dist/conversions/index.d.cts +2 -2
- package/dist/conversions/index.d.ts +2 -2
- package/dist/conversions/index.js +6 -6
- package/dist/conversions-BFz6MKaV.cjs +449 -0
- package/dist/conversions-BFz6MKaV.cjs.map +1 -0
- package/dist/{conversions-CA_3PTAH.js → conversions-Ben5p5Ts.js} +43 -40
- package/dist/conversions-Ben5p5Ts.js.map +1 -0
- package/dist/errors/index.cjs +13 -0
- package/dist/errors/index.d.cts +180 -0
- package/dist/errors/index.d.ts +180 -0
- package/dist/errors/index.js +11 -0
- package/dist/events/index.cjs +10 -9
- package/dist/events/index.cjs.map +1 -1
- package/dist/events/index.d.cts +185 -100
- package/dist/events/index.d.ts +185 -100
- package/dist/events/index.js +9 -8
- package/dist/events/index.js.map +1 -1
- package/dist/formatter-ekJQF_bA-BepnCBkQ.cjs +67 -0
- package/dist/formatter-ekJQF_bA-BepnCBkQ.cjs.map +1 -0
- package/dist/formatter-ekJQF_bA-xLD9mGk4.js +55 -0
- package/dist/formatter-ekJQF_bA-xLD9mGk4.js.map +1 -0
- package/dist/formatters/index.cjs +2 -2
- package/dist/formatters/index.d.cts +2 -2
- package/dist/formatters/index.d.ts +2 -2
- package/dist/formatters/index.js +2 -2
- package/dist/{formatters-Bm3a_akj.js → formatters-BAbGsnYA.js} +78 -71
- package/dist/formatters-BAbGsnYA.js.map +1 -0
- package/dist/formatters-zd0Gs4Cs.cjs +436 -0
- package/dist/formatters-zd0Gs4Cs.cjs.map +1 -0
- package/dist/generators/index.cjs +37 -31
- package/dist/generators/index.cjs.map +1 -1
- package/dist/generators/index.d.cts +2 -2
- package/dist/generators/index.d.ts +2 -2
- package/dist/generators/index.js +29 -23
- package/dist/generators/index.js.map +1 -1
- package/dist/hasOwnProp-CVIhlD1i.js +47 -0
- package/dist/hasOwnProp-CVIhlD1i.js.map +1 -0
- package/dist/hasOwnProp-D9Tpgokd.cjs +53 -0
- package/dist/hasOwnProp-D9Tpgokd.cjs.map +1 -0
- package/dist/{index-CakviK5E.d.cts → index-9JsU_wMu.d.ts} +1375 -937
- package/dist/{index-BqkYm8qT.d.ts → index-BP3sUrAx.d.ts} +242 -133
- package/dist/{index-CJx0EFQ4.d.cts → index-BVovC-yK.d.cts} +229 -200
- package/dist/index-C1X6ha9s.d.cts +1041 -0
- package/dist/index-CcPQZ41G.d.cts +1103 -0
- package/dist/index-CjpbuJF4.d.ts +2424 -0
- package/dist/index-CssrQyHh.d.cts +2424 -0
- package/dist/index-DZHiYYR7.d.cts +2179 -0
- package/dist/index-DZHiYYR7.d.ts +2179 -0
- package/dist/index-DlyDmXUo.d.ts +1103 -0
- package/dist/index-Dm4a___O.d.ts +1041 -0
- package/dist/{index-D5nTp1kV.d.ts → index-Dwduk7ez.d.cts} +1375 -937
- package/dist/{index-uaHl0X-r.d.cts → index-I5V6RbZM.d.cts} +1592 -790
- package/dist/{index-Bm5odgLW.d.ts → index-hOqBIL7F.d.ts} +1592 -790
- package/dist/{index-hOCUw-B9.d.ts → index-jyuOZMX7.d.ts} +229 -200
- package/dist/{index-BqkYm8qT.d.cts → index-lI0b7iUz.d.cts} +242 -133
- package/dist/{isBigInt-f6yY2fAV.js → isBigInt-Cez32M69.js} +2 -2
- package/dist/isBigInt-Cez32M69.js.map +1 -0
- package/dist/{isBigInt-CqZNWVtI.cjs → isBigInt-YgpNKTbA.cjs} +2 -2
- package/dist/isBigInt-YgpNKTbA.cjs.map +1 -0
- package/dist/{isEmptyString-Ga77_3Q1.js → isEmptyString-C9QLWjx2.js} +4 -4
- package/dist/isEmptyString-C9QLWjx2.js.map +1 -0
- package/dist/{isEmptyString-DNMPmS-H.cjs → isEmptyString-O4TFe1Ao.cjs} +5 -5
- package/dist/isEmptyString-O4TFe1Ao.cjs.map +1 -0
- package/dist/isEmptyValue-CFExALXZ.cjs +54 -0
- package/dist/isEmptyValue-CFExALXZ.cjs.map +1 -0
- package/dist/isEmptyValue-kCjnLjbN.js +36 -0
- package/dist/isEmptyValue-kCjnLjbN.js.map +1 -0
- package/dist/{isFinite-Crw95XV8.cjs → isFinite-B_hHbDpa.cjs} +6 -6
- package/dist/isFinite-B_hHbDpa.cjs.map +1 -0
- package/dist/{isFinite-BJO7Dt6B.js → isFinite-ZvNhyHlF.js} +5 -5
- package/dist/isFinite-ZvNhyHlF.js.map +1 -0
- package/dist/{isInteger-B75voxys.js → isInteger-aZgzTTZG.js} +4 -4
- package/dist/isInteger-aZgzTTZG.js.map +1 -0
- package/dist/{isInteger-CSMNm--9.cjs → isInteger-dnc6W63Z.cjs} +4 -4
- package/dist/isInteger-dnc6W63Z.cjs.map +1 -0
- package/dist/isNumber-BCWD4dW0.js +20 -0
- package/dist/isNumber-BCWD4dW0.js.map +1 -0
- package/dist/isNumber-BkzwAe50.cjs +26 -0
- package/dist/isNumber-BkzwAe50.cjs.map +1 -0
- package/dist/isPlainObject-CAe_ElKO.d.cts +331 -0
- package/dist/isPlainObject-CJvRG4Je.d.ts +331 -0
- package/dist/{isServer-BHOSvBhV.js → isServer-CQzrX5e0.js} +2 -2
- package/dist/isServer-CQzrX5e0.js.map +1 -0
- package/dist/{isServer-HA13Dzo2.cjs → isServer-DhFaedeT.cjs} +2 -2
- package/dist/isServer-DhFaedeT.cjs.map +1 -0
- package/dist/{isEqual-D8W3Wizi.cjs → isTypedArray-DjADSu8q.cjs} +45 -13
- package/dist/isTypedArray-DjADSu8q.cjs.map +1 -0
- package/dist/{isEqual-ekId-j5b.js → isTypedArray-DxsPKrLh.js} +29 -9
- package/dist/isTypedArray-DxsPKrLh.js.map +1 -0
- package/dist/{isValidDomain-BqyLVi7S.js → isValidDomain-CDtNOhMc.js} +13 -54
- package/dist/isValidDomain-CDtNOhMc.js.map +1 -0
- package/dist/{isValidDomain-ByrOfQsh.cjs → isValidDomain-D_x7uNIu.cjs} +16 -69
- package/dist/isValidDomain-D_x7uNIu.cjs.map +1 -0
- package/dist/{assertIsBoolean-DDhQ2D-k.js → logger-CLWnKRKE.js} +657 -587
- package/dist/logger-CLWnKRKE.js.map +1 -0
- package/dist/{assertIsBoolean-CEx4KbHg.cjs → logger-CUacYy3D.cjs} +658 -612
- package/dist/logger-CUacYy3D.cjs.map +1 -0
- package/dist/{noop-CkwxErJ2.cjs → noop-CjEbNsJL.cjs} +2 -2
- package/dist/noop-CjEbNsJL.cjs.map +1 -0
- package/dist/{noop-D_Ots__Z.js → noop-qxrcogt5.js} +2 -2
- package/dist/noop-qxrcogt5.js.map +1 -0
- package/dist/{normalizeSpaces-88yaixiu.cjs → normalizeSpaces-D0_Z4qnO.cjs} +6 -9
- package/dist/normalizeSpaces-D0_Z4qnO.cjs.map +1 -0
- package/dist/{normalizeSpaces-Cat8CHtt.js → normalizeSpaces-DAsxzBEQ.js} +4 -7
- package/dist/normalizeSpaces-DAsxzBEQ.js.map +1 -0
- package/dist/operations/index.cjs +152 -22
- package/dist/operations/index.cjs.map +1 -1
- package/dist/operations/index.d.cts +257 -35
- package/dist/operations/index.d.ts +257 -35
- package/dist/operations/index.js +142 -13
- package/dist/operations/index.js.map +1 -1
- package/dist/parsers/index.cjs +2 -2
- package/dist/parsers/index.d.cts +238 -180
- package/dist/parsers/index.d.ts +238 -180
- package/dist/parsers/index.js +2 -2
- package/dist/{parsers-BLHzVoh-.js → parsers-BBAE_xVM.js} +9 -8
- package/dist/parsers-BBAE_xVM.js.map +1 -0
- package/dist/{parsers-xAQmKCgS.cjs → parsers-i8WEeMJl.cjs} +10 -9
- package/dist/parsers-i8WEeMJl.cjs.map +1 -0
- package/dist/{parsing-BYo6U0EG.js → parsing-D9tbKQ0v.js} +3 -3
- package/dist/parsing-D9tbKQ0v.js.map +1 -0
- package/dist/{parsing-CuezVd0e.cjs → parsing-DGjB8cwr.cjs} +4 -4
- package/dist/parsing-DGjB8cwr.cjs.map +1 -0
- package/dist/predicates/index.cjs +43 -43
- package/dist/predicates/index.d.cts +3 -3
- package/dist/predicates/index.d.ts +3 -3
- package/dist/predicates/index.js +14 -14
- package/dist/{predicates-BMTIIYx8.js → predicates-C0dova7l.js} +45 -40
- package/dist/predicates-C0dova7l.js.map +1 -0
- package/dist/{predicates-ZmZpelMh.cjs → predicates-Dd7To7B4.cjs} +89 -84
- package/dist/predicates-Dd7To7B4.cjs.map +1 -0
- package/dist/promises/index.cjs +27 -26
- package/dist/promises/index.cjs.map +1 -1
- package/dist/promises/index.d.cts +227 -75
- package/dist/promises/index.d.ts +227 -75
- package/dist/promises/index.js +27 -26
- package/dist/promises/index.js.map +1 -1
- package/dist/{punyCode-WZ6-GaTM.cjs → punyCode-DHTLhGdD.cjs} +12 -12
- package/dist/punyCode-DHTLhGdD.cjs.map +1 -0
- package/dist/{punyCode-COTqgXMJ.js → punyCode-Deb1Mrkc.js} +12 -12
- package/dist/punyCode-Deb1Mrkc.js.map +1 -0
- package/dist/{removeSpaces-CQJvw1yU.js → removeSpaces-BPnsdRN0.js} +4 -4
- package/dist/removeSpaces-BPnsdRN0.js.map +1 -0
- package/dist/{removeSpaces-BeGkktUl.cjs → removeSpaces-CN3pxBz_.cjs} +7 -7
- package/dist/removeSpaces-CN3pxBz_.cjs.map +1 -0
- package/dist/rzl-utils.global.js +13 -13
- package/dist/safeJsonParse-D1FLVTEM.cjs +209 -0
- package/dist/safeJsonParse-D1FLVTEM.cjs.map +1 -0
- package/dist/{safeJsonParse-D8H3wCv7.js → safeJsonParse-DEVKNDSn.js} +29 -28
- package/dist/safeJsonParse-DEVKNDSn.js.map +1 -0
- package/dist/safeStableStringify-C5HHKUdn.cjs +125 -0
- package/dist/safeStableStringify-C5HHKUdn.cjs.map +1 -0
- package/dist/{safeStableStringify-BLwA1VC-.js → safeStableStringify-DfwxmiWn.js} +20 -13
- package/dist/safeStableStringify-DfwxmiWn.js.map +1 -0
- package/dist/strings/index.cjs +26 -30
- package/dist/strings/index.cjs.map +1 -1
- package/dist/strings/index.d.cts +2 -2
- package/dist/strings/index.d.ts +2 -2
- package/dist/strings/index.js +13 -17
- package/dist/strings/index.js.map +1 -1
- package/dist/tailwind/index.cjs +3 -3
- package/dist/tailwind/index.d.cts +3 -3
- package/dist/tailwind/index.d.ts +3 -3
- package/dist/tailwind/index.js +3 -3
- package/dist/{tailwind-CjxdO7aL.cjs → tailwind-BG7B0cDs.cjs} +59 -53
- package/dist/tailwind-BG7B0cDs.cjs.map +1 -0
- package/dist/{tailwind-RSE3obLb.js → tailwind-tJNnFPsF.js} +38 -32
- package/dist/tailwind-tJNnFPsF.js.map +1 -0
- package/dist/{toStringArrayUnRecursive-NreW1dyV.js → toStringArrayUnRecursive-D0WbLIRz.js} +9 -9
- package/dist/toStringArrayUnRecursive-D0WbLIRz.js.map +1 -0
- package/dist/toStringArrayUnRecursive-QLoaNX_-.cjs +51 -0
- package/dist/toStringArrayUnRecursive-QLoaNX_-.cjs.map +1 -0
- package/dist/urls/index.cjs +3 -3
- package/dist/urls/index.d.cts +635 -443
- package/dist/urls/index.d.ts +635 -443
- package/dist/urls/index.js +3 -3
- package/dist/{urls-CLVfEB7O.js → urls-EoWslGgg.js} +50 -41
- package/dist/urls-EoWslGgg.js.map +1 -0
- package/dist/urls-NCzPepe2.cjs +308 -0
- package/dist/urls-NCzPepe2.cjs.map +1 -0
- package/package.json +6 -6
- package/dist/assertIsArray-CqIFmlgj.cjs.map +0 -1
- package/dist/assertIsArray-DrLORH0Y.js.map +0 -1
- package/dist/assertIsBoolean-CEx4KbHg.cjs.map +0 -1
- package/dist/assertIsBoolean-DDhQ2D-k.js.map +0 -1
- package/dist/assertIsString-1iLqxrN0.js.map +0 -1
- package/dist/assertIsString-DGDLC-XD.cjs.map +0 -1
- package/dist/conversions-Bxa01uIl.cjs +0 -446
- package/dist/conversions-Bxa01uIl.cjs.map +0 -1
- package/dist/conversions-CA_3PTAH.js.map +0 -1
- package/dist/formatters-Bm3a_akj.js.map +0 -1
- package/dist/formatters-Bt6QuhxK.cjs +0 -429
- package/dist/formatters-Bt6QuhxK.cjs.map +0 -1
- package/dist/index--h04HuBE.d.cts +0 -765
- package/dist/index--h04HuBE.d.ts +0 -765
- package/dist/index-Ap8U-8Qx.d.cts +0 -947
- package/dist/index-BAeeggeh.d.cts +0 -1716
- package/dist/index-BAeeggeh.d.ts +0 -1716
- package/dist/index-CMglhpFG.d.ts +0 -947
- package/dist/isBigInt-CqZNWVtI.cjs.map +0 -1
- package/dist/isBigInt-f6yY2fAV.js.map +0 -1
- package/dist/isEmptyObject-BYNnSKzw.js +0 -25
- package/dist/isEmptyObject-BYNnSKzw.js.map +0 -1
- package/dist/isEmptyObject-C2lQyFZS.cjs +0 -37
- package/dist/isEmptyObject-C2lQyFZS.cjs.map +0 -1
- package/dist/isEmptyString-DNMPmS-H.cjs.map +0 -1
- package/dist/isEmptyString-Ga77_3Q1.js.map +0 -1
- package/dist/isEmptyValue-D7-6WWS9.js +0 -24
- package/dist/isEmptyValue-D7-6WWS9.js.map +0 -1
- package/dist/isEmptyValue-DZaDHEIw.cjs +0 -30
- package/dist/isEmptyValue-DZaDHEIw.cjs.map +0 -1
- package/dist/isEqual-D8W3Wizi.cjs.map +0 -1
- package/dist/isEqual-ekId-j5b.js.map +0 -1
- package/dist/isFinite-BJO7Dt6B.js.map +0 -1
- package/dist/isFinite-Crw95XV8.cjs.map +0 -1
- package/dist/isInteger-B75voxys.js.map +0 -1
- package/dist/isInteger-CSMNm--9.cjs.map +0 -1
- package/dist/isPlainObject-ByfuseCf.d.cts +0 -339
- package/dist/isPlainObject-ByfuseCf.d.ts +0 -339
- package/dist/isServer-BHOSvBhV.js.map +0 -1
- package/dist/isServer-HA13Dzo2.cjs.map +0 -1
- package/dist/isTypedArray-CWlHRz_O.cjs +0 -43
- package/dist/isTypedArray-CWlHRz_O.cjs.map +0 -1
- package/dist/isTypedArray-CmnQ7Yx9.js +0 -31
- package/dist/isTypedArray-CmnQ7Yx9.js.map +0 -1
- package/dist/isValidDomain-BqyLVi7S.js.map +0 -1
- package/dist/isValidDomain-ByrOfQsh.cjs.map +0 -1
- package/dist/noop-CkwxErJ2.cjs.map +0 -1
- package/dist/noop-D_Ots__Z.js.map +0 -1
- package/dist/normalizeSpaces-88yaixiu.cjs.map +0 -1
- package/dist/normalizeSpaces-Cat8CHtt.js.map +0 -1
- package/dist/parsers-BLHzVoh-.js.map +0 -1
- package/dist/parsers-xAQmKCgS.cjs.map +0 -1
- package/dist/parsing-BYo6U0EG.js.map +0 -1
- package/dist/parsing-CuezVd0e.cjs.map +0 -1
- package/dist/predicates-BMTIIYx8.js.map +0 -1
- package/dist/predicates-ZmZpelMh.cjs.map +0 -1
- package/dist/punyCode-COTqgXMJ.js.map +0 -1
- package/dist/punyCode-WZ6-GaTM.cjs.map +0 -1
- package/dist/removeSpaces-BeGkktUl.cjs.map +0 -1
- package/dist/removeSpaces-CQJvw1yU.js.map +0 -1
- package/dist/safeJsonParse-BznDD3fi.cjs +0 -208
- package/dist/safeJsonParse-BznDD3fi.cjs.map +0 -1
- package/dist/safeJsonParse-D8H3wCv7.js.map +0 -1
- package/dist/safeStableStringify-4b-E_UHM.cjs +0 -106
- package/dist/safeStableStringify-4b-E_UHM.cjs.map +0 -1
- package/dist/safeStableStringify-BLwA1VC-.js.map +0 -1
- package/dist/tailwind-CjxdO7aL.cjs.map +0 -1
- package/dist/tailwind-RSE3obLb.js.map +0 -1
- package/dist/toStringArrayUnRecursive-D-jHROts.cjs +0 -51
- package/dist/toStringArrayUnRecursive-D-jHROts.cjs.map +0 -1
- package/dist/toStringArrayUnRecursive-NreW1dyV.js.map +0 -1
- package/dist/urls-C6BvhrrV.cjs +0 -299
- package/dist/urls-C6BvhrrV.cjs.map +0 -1
- package/dist/urls-CLVfEB7O.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatter-ekJQF_bA-xLD9mGk4.js","names":[],"sources":["../../build-tools/dist/formatter-ekJQF_bA.js"],"sourcesContent":["/*!\n* ========================================================================\n* @rzl-zone/build-tools\n* ------------------------------------------------------------------------\n* Version: `0.0.13-beta.0`\n* Author: `Rizalvin Dwiky <rizalvindwiky1998@gmail.com>`\n* Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/build-tools`\n* ========================================================================\n*/\n\nimport pcr from \"picocolors\";\nfunction deepFreeze(value) {\n\tif (typeof value !== \"object\" || value === null) return value;\n\tconst seen = /* @__PURE__ */ new WeakSet();\n\tconst stack = [value];\n\twhile (stack.length) {\n\t\tconst obj = stack.pop();\n\t\tif (seen.has(obj) || Object.isFrozen(obj)) continue;\n\t\tseen.add(obj);\n\t\tif (isMap(obj)) for (const [k, v] of obj) {\n\t\t\tif (typeof k === \"object\" && k !== null) stack.push(k);\n\t\t\tif (typeof v === \"object\" && v !== null) stack.push(v);\n\t\t}\n\t\telse if (isSet(obj)) {\n\t\t\tfor (const v of obj) if (typeof v === \"object\" && v !== null) stack.push(v);\n\t\t} else if (isArray(obj)) {\n\t\t\tfor (const v of obj) if (typeof v === \"object\" && v !== null) stack.push(v);\n\t\t} else {\n\t\t\tconst record = obj;\n\t\t\tfor (const key of Reflect.ownKeys(record)) {\n\t\t\t\tconst v = record[key];\n\t\t\t\tif (typeof v === \"object\" && v !== null) stack.push(v);\n\t\t\t}\n\t\t}\n\t\tObject.freeze(obj);\n\t}\n\treturn value;\n}\nconst isRegExp = (value) => {\n\treturn value instanceof RegExp;\n};\nconst isString = (value) => {\n\treturn typeof value === \"string\";\n};\nfunction isSet(value) {\n\treturn Object.prototype.toString.call(value) === \"[object Set]\" || value instanceof Set;\n}\nfunction isMap(value) {\n\treturn Object.prototype.toString.call(value) === \"[object Map]\" || value instanceof Map;\n}\nfunction isArray(value) {\n\treturn Array.isArray(value);\n}\nconst isNull = (val) => val === null;\nfunction isPlainObject(value) {\n\tif (!isObject(value)) return false;\n\tconst proto = Object.getPrototypeOf(value);\n\treturn proto === Object.prototype || proto === null;\n}\nfunction isObject(value) {\n\treturn typeof value === \"object\" && !isNil(value) && !isArray(value);\n}\nfunction isObjectOrArray(value) {\n\treturn isArray(value) || isObject(value);\n}\nconst isNil = (value) => {\n\treturn value == null;\n};\nconst isBoolean = (value) => {\n\treturn typeof value === \"boolean\";\n};\nconst isUndefined = (value) => {\n\treturn typeof value === \"undefined\";\n};\nconst isFunction = (value) => {\n\treturn typeof value === \"function\";\n};\nconst isNumberObject = (value) => {\n\treturn isObject(value) && Object.prototype.toString.call(value) === \"[object Number]\";\n};\nconst isStringObject = (value) => {\n\treturn isObject(value) && Object.prototype.toString.call(value) === \"[object String]\";\n};\nconst isBooleanObject = (value) => {\n\treturn isObject(value) && Object.prototype.toString.call(value) === \"[object Boolean]\";\n};\nconst isInfinityNumber = (value) => {\n\tif (typeof value === \"number\" || isNumberObject(value)) {\n\t\tconst num = Number(value);\n\t\treturn num === Infinity || num === -Infinity;\n\t}\n\treturn false;\n};\nconst isSymbol = (value) => {\n\treturn typeof value === \"symbol\";\n};\nconst isBigInt = (value) => {\n\treturn typeof value === \"bigint\";\n};\nconst isNaN = (value) => {\n\treturn typeof value === \"number\" ? Number.isNaN(value) : isNumberObject(value) && Number.isNaN(value.valueOf());\n};\nconst isNonEmptyString = (value, options = {}) => {\n\tif (!isString(value)) return false;\n\treturn (options.trim ?? true ? value.trim() : value).length > 0;\n};\nconst isNumber = (value, options = {}) => {\n\tconst includeNaN = isPlainObject(options) && isBoolean(options.includeNaN) ? options.includeNaN : false;\n\tconst aNumber = typeof value === \"number\";\n\treturn includeNaN ? aNumber : aNumber && !Number.isNaN(value);\n};\nconst isError = (error) => {\n\treturn Object.prototype.toString.call(error) === \"[object Error]\" || error instanceof Error;\n};\nconst isDate = (value, options = {}) => {\n\tconst skipInvalidDate = isPlainObject(options) && isBoolean(options.skipInvalidDate) ? options.skipInvalidDate : false;\n\tconst instanceDate = value instanceof Date;\n\tif (skipInvalidDate) return instanceDate;\n\treturn instanceDate && !isNaN(value.getTime());\n};\nconst safeStableStringify = (value, options = {}) => {\n\tconst pretty = options.pretty ?? false;\n\tconst sortKeys = options.sortKeys ?? true;\n\tconst sortArray = options.sortArray ?? false;\n\tconst keepUndefined = options.keepUndefined ?? false;\n\tif (isUndefined(value)) return keepUndefined ? \"undefined\" : \"null\";\n\tconst seen = /* @__PURE__ */ new WeakSet();\n\tconst isPrimitive = (val) => isNull(val) || !isObjectOrArray(val) && !isFunction(val);\n\tconst deepProcess = (val) => {\n\t\tif (isNumberObject(val)) {\n\t\t\tconst valOf = val.valueOf();\n\t\t\treturn isNaN(valOf) || isInfinityNumber(valOf) ? null : valOf;\n\t\t}\n\t\tif (isStringObject(val)) return val.valueOf();\n\t\tif (isBooleanObject(val)) return val.valueOf();\n\t\tif (isFunction(val) || isSymbol(val)) return void 0;\n\t\tif (isBigInt(val)) return val.toString();\n\t\tif (isNaN(val) || isInfinityNumber(val)) return null;\n\t\tif (isUndefined(val)) return keepUndefined ? void 0 : null;\n\t\tif (isObjectOrArray(val)) {\n\t\t\tif (seen.has(val)) return \"[Circular]\";\n\t\t\tseen.add(val);\n\t\t\tif (isDate(val)) return val.toISOString();\n\t\t\tif (isMap(val)) return { map: Array.from(val.entries()).map(([k, v]) => [k, deepProcess(v)]) };\n\t\t\tif (isSet(val)) return { set: Array.from(val.values()).map(deepProcess) };\n\t\t\tif (isArray(val)) {\n\t\t\t\tconst processedArr = val.map(deepProcess);\n\t\t\t\tif (sortArray) {\n\t\t\t\t\tconst primitives = [];\n\t\t\t\t\tconst nonPrimitives = [];\n\t\t\t\t\tfor (const item of processedArr) if (isPrimitive(item)) primitives.push(item);\n\t\t\t\t\telse nonPrimitives.push(item);\n\t\t\t\t\tprimitives.sort((a, b) => {\n\t\t\t\t\t\tif (isNumber(a) && isNumber(b)) return a - b;\n\t\t\t\t\t\treturn String(a).localeCompare(String(b));\n\t\t\t\t\t});\n\t\t\t\t\treturn [...primitives, ...nonPrimitives];\n\t\t\t\t}\n\t\t\t\treturn processedArr;\n\t\t\t}\n\t\t\tconst keys = Object.keys(val);\n\t\t\tif (sortKeys) keys.sort((a, b) => {\n\t\t\t\tconst na = Number(a);\n\t\t\t\tconst nb = Number(b);\n\t\t\t\tif (!isNaN(na) && !isNaN(nb)) return na - nb;\n\t\t\t\treturn a.localeCompare(b);\n\t\t\t});\n\t\t\tconst result = {};\n\t\t\tif (isObject(val)) for (const k of keys) {\n\t\t\t\tconst v = deepProcess(val[k]);\n\t\t\t\tif (!isUndefined(v)) result[k] = v;\n\t\t\t}\n\t\t\treturn result;\n\t\t}\n\t\treturn val;\n\t};\n\ttry {\n\t\treturn JSON.stringify(deepProcess(value), null, pretty ? 2 : 0);\n\t} catch (err) {\n\t\tconsole.warn(\"Error in safeStableStringify:\", err);\n\t\treturn \"{}\";\n\t}\n};\nconst normalizeSpaces = (value, options = {\n\twithTrim: true,\n\ttrimOnly: false\n}) => {\n\tif (!isNonEmptyString(value)) return \"\";\n\tif (!isPlainObject(options)) options = {};\n\tconst { trimOnly = false, withTrim = true } = options;\n\tif (trimOnly) return value.trim();\n\tif (withTrim) value = value.trim();\n\treturn value.replace(/\\s+/g, \" \");\n};\nconst isStringArray = (v) => isArray(v) && v.every((i) => isString(i));\nconst isStringSet = (v) => isSet(v) && [...v].every((i) => isString(i));\nconst assertValidatePatternArgs = (v, parameterKey = \"pattern\") => {\n\tif (!isString(v) && !isStringArray(v) && !isStringSet(v)) throw new TypeError(`The \\`${parameterKey}\\` argument must be a string, string[] or Set<string>.`);\n};\nconst flattenStrings = (input) => {\n\treturn input.flat(Infinity).filter((v) => typeof v === \"string\");\n};\nconst toStringSet = (pattern, options = {}) => {\n\tconst { withValidationType = true, parameterKey = \"pattern\" } = options;\n\tif (withValidationType) assertValidatePatternArgs(pattern, parameterKey);\n\treturn toObjectSet(pattern);\n};\nconst toObjectSet = (value) => {\n\tif (isSet(value)) return value;\n\treturn new Set(isArray(value) ? value : [value]);\n};\nconst toArray = (value) => {\n\treturn isArray(value) ? value : [value];\n};\nconst hasGlobalRequire = (value) => isObject(value) && isFunction(value.require);\nconst getRuntimeRequire = () => {\n\tif (!hasGlobalRequire(globalThis)) return void 0;\n\treturn globalThis.require;\n};\nconst __runtimeRequire = ((x) => {\n\tconst r = getRuntimeRequire();\n\tif (r) return r;\n\tif (typeof Proxy !== \"undefined\") return new Proxy(x, { get(target, prop) {\n\t\tconst r2 = getRuntimeRequire();\n\t\treturn r2 ? r2[prop] : target[prop];\n\t} });\n\treturn x;\n})(function(id) {\n\tconst r = getRuntimeRequire();\n\tif (r) return r.call(this, id);\n\tthrow new Error(`Calling \\`require\\` for \"${id}\" in an environment that doesn't expose the \\`require\\` function.`);\n});\nconst picocolors = pcr;\nconst NEWLINE = atob(\"Cg==\");\nconst EOL = hasGlobalRequire(globalThis) ? __runtimeRequire(\"node:os\").EOL : NEWLINE;\nfunction plural(count, word, pluralWord) {\n\tif (count === 1) return word;\n\treturn pluralWord ?? `${word}s`;\n}\nfunction padText(value, options = {}) {\n\tconst { start = true, end = true, padOnInvalid = true } = options;\n\tif (!isNonEmptyString(value)) return padOnInvalid ? \" \" : \"\";\n\treturn `${start ? \" \" : \"\"}${value}${end ? \" \" : \"\"}`;\n}\nfunction joinInline(...text) {\n\treturn text.filter(Boolean).join(\" \");\n}\nfunction joinLines(...text) {\n\treturn text.filter(Boolean).join(EOL);\n}\nfunction joinLinesLoose(...text) {\n\treturn text.filter((v) => v !== false && v !== null && v !== void 0).join(EOL);\n}\nfunction formatOptionValue(value, options) {\n\tconst { pretty = false, indent = 2, sortKeys = false, sortArray = false } = options ?? {};\n\tconst indentUnit = \" \".repeat(indent);\n\tfunction formatRecursive(input, depth = 0) {\n\t\tconst currentIndent = indentUnit.repeat(depth);\n\t\tconst nextIndent = indentUnit.repeat(depth + 1);\n\t\tconst joinInline = picocolors.dim(\", \");\n\t\tconst joinPretty = `,${EOL}`;\n\t\tif (isSet(input)) return formatRecursive([...input], depth);\n\t\tif (isMap(input)) return formatRecursive(Object.fromEntries(input), depth);\n\t\tif (isArray(input)) {\n\t\t\tconst arr = sortArray ? [...input].sort() : input;\n\t\t\tif (arr.length === 0) return picocolors.gray(\"[]\");\n\t\t\tif (!pretty) {\n\t\t\t\tconst items = arr.map((v) => formatRecursive(v, depth)).join(joinInline);\n\t\t\t\treturn picocolors.gray(\"[\") + items + picocolors.gray(\"]\");\n\t\t\t}\n\t\t\tconst items = arr.map((v) => nextIndent + formatRecursive(v, depth + 1)).join(joinPretty);\n\t\t\treturn picocolors.gray(`[${EOL}`) + items + EOL + currentIndent + picocolors.gray(\"]\");\n\t\t}\n\t\tif (isPlainObject(input)) {\n\t\t\tlet entries = Object.entries(input);\n\t\t\tif (sortKeys) entries = entries.sort(([a], [b]) => a.localeCompare(b));\n\t\t\tif (entries.length === 0) return picocolors.gray(\"{}\");\n\t\t\tif (!pretty) {\n\t\t\t\tconst props = entries.map(([key, val]) => {\n\t\t\t\t\treturn picocolors.dim(key) + picocolors.gray(\": \") + formatRecursive(val, depth);\n\t\t\t\t}).join(joinInline);\n\t\t\t\treturn picocolors.gray(\"{ \") + props + picocolors.gray(\" }\");\n\t\t\t}\n\t\t\tconst props = entries.map(([key, val]) => {\n\t\t\t\treturn nextIndent + picocolors.dim(key) + picocolors.gray(\": \") + formatRecursive(val, depth + 1);\n\t\t\t}).join(joinPretty);\n\t\t\treturn picocolors.gray(`{${EOL}`) + props + EOL + currentIndent + picocolors.gray(\"}\");\n\t\t}\n\t\tif (isRegExp(input)) return picocolors.greenBright(\"/\") + picocolors.redBright(input.source) + picocolors.greenBright(\"/\") + picocolors.magentaBright(input.flags);\n\t\tif (isString(input)) return picocolors.gray(`\"${input}\"`);\n\t\tif (isNumber(input, { includeNaN: true })) return picocolors.redBright(String(input));\n\t\tif (isBoolean(input)) return picocolors.redBright(String(input));\n\t\tif (isNil(input)) return picocolors.redBright(String(input));\n\t\tif (isObject(input)) return picocolors.cyanBright(Object.prototype.toString.call(input));\n\t\treturn picocolors.cyanBright(String(input));\n\t}\n\treturn formatRecursive(value);\n}\nexport { isString as C, toArray as D, safeStableStringify as E, toObjectSet as O, isSet as S, normalizeSpaces as T, isNonEmptyString as _, joinLines as a, isPlainObject as b, picocolors as c, flattenStrings as d, isArray as f, isNil as g, isFunction as h, joinInline as i, toStringSet as k, plural as l, isError as m, NEWLINE as n, joinLinesLoose as o, isBoolean as p, formatOptionValue as r, padText as s, EOL as t, deepFreeze as u, isNull as v, isUndefined as w, isRegExp as x, isNumber as y };\n//# sourceMappingURL=formatter-ekJQF_bA.js.map\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAkDA,SAAS,QAAQ,OAAO;CACvB,OAAO,MAAM,QAAQ,KAAK;AAC3B;AAOA,SAAS,SAAS,OAAO;CACxB,OAAO,OAAO,UAAU,YAAY,CAAC,MAAM,KAAK,KAAK,CAAC,QAAQ,KAAK;AACpE;AAIA,MAAM,SAAS,UAAU;CACxB,OAAO,SAAS;AACjB;AAOA,MAAM,cAAc,UAAU;CAC7B,OAAO,OAAO,UAAU;AACzB;AA0IA,MAAM,oBAAoB,UAAU,SAAS,KAAK,KAAK,WAAW,MAAM,OAAO;AAC/E,MAAM,0BAA0B;CAC/B,IAAI,CAAC,iBAAiB,UAAU,GAAG,OAAO,KAAK;CAC/C,OAAO,WAAW;AACnB;AACA,MAAM,qBAAqB,MAAM;CAChC,MAAM,IAAI,kBAAkB;CAC5B,IAAI,GAAG,OAAO;CACd,IAAI,OAAO,UAAU,aAAa,OAAO,IAAI,MAAM,GAAG,EAAE,IAAI,QAAQ,MAAM;EACzE,MAAM,KAAK,kBAAkB;EAC7B,OAAO,KAAK,GAAG,QAAQ,OAAO;CAC/B,EAAE,CAAC;CACH,OAAO;AACR,GAAG,SAAS,IAAI;CACf,MAAM,IAAI,kBAAkB;CAC5B,IAAI,GAAG,OAAO,EAAE,KAAK,MAAM,EAAE;CAC7B,MAAM,IAAI,MAAM,4BAA4B,GAAG,kEAAkE;AAClH,CAAC;AAED,MAAM,UAAU,KAAK,MAAM;AAC3B,MAAM,MAAM,iBAAiB,UAAU,IAAI,iBAAiB,SAAS,EAAE,MAAM;AAa7E,SAAS,UAAU,GAAG,MAAM;CAC3B,OAAO,KAAK,OAAO,OAAO,EAAE,KAAK,GAAG;AACrC"}
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
* ========================================================================
|
|
3
3
|
* @rzl-zone/utils-js
|
|
4
4
|
* ------------------------------------------------------------------------
|
|
5
|
-
* Version: `3.
|
|
5
|
+
* Version: `3.14.0-beta.0`
|
|
6
6
|
* Author: `Rizalvin Dwiky <rizalvindwiky@gmail.com>`
|
|
7
7
|
* Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/utils-js`
|
|
8
8
|
* ========================================================================
|
|
9
9
|
*/
|
|
10
10
|
"use strict";
|
|
11
11
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
12
|
-
const require_formatters = require('../formatters-
|
|
12
|
+
const require_formatters = require('../formatters-zd0Gs4Cs.cjs');
|
|
13
13
|
exports.censorEmail = require_formatters.censorEmail;
|
|
14
14
|
exports.chunkString = require_formatters.chunkString;
|
|
15
15
|
exports.formatCurrency = require_formatters.formatCurrency;
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
* ========================================================================
|
|
3
3
|
* @rzl-zone/utils-js
|
|
4
4
|
* ------------------------------------------------------------------------
|
|
5
|
-
* Version: `3.
|
|
5
|
+
* Version: `3.14.0-beta.0`
|
|
6
6
|
* Author: `Rizalvin Dwiky <rizalvindwiky@gmail.com>`
|
|
7
7
|
* Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/utils-js`
|
|
8
8
|
* ========================================================================
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import { a as truncateString, c as formatPhoneNumber, i as formatDateFns, l as formatNumber, n as formatDateTime, o as chunkString, r as formatDateIntl, s as censorEmail, t as getGMTOffset, u as formatCurrency } from "../index-
|
|
11
|
+
import { a as truncateString, c as formatPhoneNumber, i as formatDateFns, l as formatNumber, n as formatDateTime, o as chunkString, r as formatDateIntl, s as censorEmail, t as getGMTOffset, u as formatCurrency } from "../index-Dwduk7ez.cjs";
|
|
12
12
|
export { censorEmail, chunkString, formatCurrency, formatDateFns, formatDateIntl, formatDateTime, formatNumber, formatPhoneNumber, getGMTOffset, truncateString };
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
* ========================================================================
|
|
3
3
|
* @rzl-zone/utils-js
|
|
4
4
|
* ------------------------------------------------------------------------
|
|
5
|
-
* Version: `3.
|
|
5
|
+
* Version: `3.14.0-beta.0`
|
|
6
6
|
* Author: `Rizalvin Dwiky <rizalvindwiky@gmail.com>`
|
|
7
7
|
* Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/utils-js`
|
|
8
8
|
* ========================================================================
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import { a as truncateString, c as formatPhoneNumber, i as formatDateFns, l as formatNumber, n as formatDateTime, o as chunkString, r as formatDateIntl, s as censorEmail, t as getGMTOffset, u as formatCurrency } from "../index-
|
|
11
|
+
import { a as truncateString, c as formatPhoneNumber, i as formatDateFns, l as formatNumber, n as formatDateTime, o as chunkString, r as formatDateIntl, s as censorEmail, t as getGMTOffset, u as formatCurrency } from "../index-9JsU_wMu.js";
|
|
12
12
|
export { censorEmail, chunkString, formatCurrency, formatDateFns, formatDateIntl, formatDateTime, formatNumber, formatPhoneNumber, getGMTOffset, truncateString };
|
package/dist/formatters/index.js
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
* ========================================================================
|
|
3
3
|
* @rzl-zone/utils-js
|
|
4
4
|
* ------------------------------------------------------------------------
|
|
5
|
-
* Version: `3.
|
|
5
|
+
* Version: `3.14.0-beta.0`
|
|
6
6
|
* Author: `Rizalvin Dwiky <rizalvindwiky@gmail.com>`
|
|
7
7
|
* Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/utils-js`
|
|
8
8
|
* ========================================================================
|
|
9
9
|
*/
|
|
10
|
-
import { a as truncateString, c as formatPhoneNumber, i as formatDateFns, l as formatNumber, n as formatDateTime, o as chunkString, r as formatDateIntl, s as censorEmail, t as getGMTOffset, u as formatCurrency } from "../formatters-
|
|
10
|
+
import { a as truncateString, c as formatPhoneNumber, i as formatDateFns, l as formatNumber, n as formatDateTime, o as chunkString, r as formatDateIntl, s as censorEmail, t as getGMTOffset, u as formatCurrency } from "../formatters-BAbGsnYA.js";
|
|
11
11
|
export { censorEmail, chunkString, formatCurrency, formatDateFns, formatDateIntl, formatDateTime, formatNumber, formatPhoneNumber, getGMTOffset, truncateString };
|
|
@@ -2,19 +2,21 @@
|
|
|
2
2
|
* ========================================================================
|
|
3
3
|
* @rzl-zone/utils-js
|
|
4
4
|
* ------------------------------------------------------------------------
|
|
5
|
-
* Version: `3.
|
|
5
|
+
* Version: `3.14.0-beta.0`
|
|
6
6
|
* Author: `Rizalvin Dwiky <rizalvindwiky@gmail.com>`
|
|
7
7
|
* Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/utils-js`
|
|
8
8
|
* ========================================================================
|
|
9
9
|
*/
|
|
10
|
-
import { A as
|
|
11
|
-
import { t as
|
|
12
|
-
import { t as
|
|
13
|
-
import {
|
|
14
|
-
import { t as
|
|
15
|
-
import { t as
|
|
16
|
-
import { t as
|
|
17
|
-
import { t as
|
|
10
|
+
import { A as isFunction, E as isPlainObject, S as isNaN, T as isString, i as getPreciseType, j as isBoolean, k as isNil, n as assertIsBoolean, t as createMessage, w as isNonEmptyString } from "./logger-CLWnKRKE.js";
|
|
11
|
+
import { t as isNumber } from "./isNumber-BCWD4dW0.js";
|
|
12
|
+
import { t as assertIsString } from "./assertIsString-CHIwE12y.js";
|
|
13
|
+
import { t as isFinite } from "./isFinite-ZvNhyHlF.js";
|
|
14
|
+
import { i as isDate, r as isUndefined, t as safeStableStringify } from "./safeStableStringify-DfwxmiWn.js";
|
|
15
|
+
import { t as isEmptyString } from "./isEmptyString-C9QLWjx2.js";
|
|
16
|
+
import { t as parseCurrencyString } from "./parsing-D9tbKQ0v.js";
|
|
17
|
+
import { t as hasOwnProp } from "./hasOwnProp-CVIhlD1i.js";
|
|
18
|
+
import { t as isInteger } from "./isInteger-aZgzTTZG.js";
|
|
19
|
+
import { t as normalizeSpaces } from "./normalizeSpaces-DAsxzBEQ.js";
|
|
18
20
|
import { AsYouType, isSupportedCountry } from "libphonenumber-js/max";
|
|
19
21
|
import { enUS, id } from "date-fns/locale";
|
|
20
22
|
import { format, parse } from "date-fns";
|
|
@@ -24,24 +26,24 @@ const formatIndianNumber = ({ numStr, separator }) => {
|
|
|
24
26
|
if (!rest) return lastThree;
|
|
25
27
|
return rest.replace(/\B(?=(\d{2})+(?!\d))/g, separator) + separator + lastThree;
|
|
26
28
|
};
|
|
27
|
-
const formatCurrency = (value, options
|
|
28
|
-
if (!isString(value) && !isFinite(value)) throw new TypeError(`First parameter (\`value\`) must be of type \`string\` or \`primitive-number\`, but received: \`${getPreciseType(value)}\`, with value: \`${safeStableStringify(value, { keepUndefined: true })}\`.`);
|
|
29
|
-
|
|
30
|
-
const decimal =
|
|
31
|
-
const totalDecimal =
|
|
32
|
-
const endDecimal =
|
|
33
|
-
const indianFormat =
|
|
34
|
-
const suffixCurrency =
|
|
35
|
-
const suffixDecimal =
|
|
36
|
-
const roundedDecimal =
|
|
37
|
-
const negativeFormat =
|
|
38
|
-
let separatorDecimals =
|
|
39
|
-
let separator =
|
|
40
|
-
if (!isString(separator) || !isString(separatorDecimals) || !isString(suffixCurrency) || !isString(suffixDecimal)) throw new TypeError(`Parameter \`separator\`, \`separatorDecimals\`, \`suffixCurrency\` and \`suffixDecimal\` property of the \`options\` (second parameter) must be of type \`string\`, but received: ['separator': \`${getPreciseType(separator)}\`, 'separatorDecimals': \`${getPreciseType(separatorDecimals)}\`, 'suffixCurrency': \`${getPreciseType(suffixCurrency)}\`, 'suffixDecimal': \`${getPreciseType(suffixDecimal)}\`].`);
|
|
41
|
-
if (!isBoolean(decimal) || !isBoolean(endDecimal) || !isBoolean(indianFormat)) throw new TypeError(`Parameter \`decimal\`, \`endDecimal\` and \`indianFormat\` property of the \`options\` (second parameter) must be of type \`boolean\`, but received: ['decimal': \`${getPreciseType(decimal)}\`, 'endDecimal': \`${getPreciseType(endDecimal)}\`, 'indianFormat': \`${getPreciseType(indianFormat)}\`].`);
|
|
42
|
-
if (!isInteger(totalDecimal)) throw new TypeError(`Parameter \`totalDecimal\` property of the \`options\` (second parameter) must be of type \`integer-number\`, but received: \`${getPreciseType(totalDecimal)}\`, with value: \`${safeStableStringify(length, { keepUndefined: true })}\`.`);
|
|
43
|
-
if (!(roundedDecimal === false || roundedDecimal === "round" || roundedDecimal === "ceil" || roundedDecimal === "floor")) throw new TypeError(`Parameter \`roundedDecimal\` property of the \`options\` (second parameter) must be of type \`false\` or \`string\` must be one of "round" | "ceil" | "floor", but received: \`${getPreciseType(roundedDecimal)}\`, with value: \`${safeStableStringify(roundedDecimal, { keepUndefined: true })}\`.`);
|
|
44
|
-
if (!(negativeFormat === "abs" || negativeFormat === "brackets" || negativeFormat === "dash" || isPlainObject(negativeFormat))) throw new TypeError(`Parameter \`negativeFormat\` property of the \`options\` (second parameter) must be of type \`string\` must be one of "abs" | "brackets" | "dash" or \`plain-object\` type, but received: \`${getPreciseType(negativeFormat)}\`, with value: \`${safeStableStringify(negativeFormat, { keepUndefined: true })}\`.`);
|
|
29
|
+
const formatCurrency = (value, options) => {
|
|
30
|
+
if (!isString(value) && !isFinite(value)) throw new TypeError(errorMsg$4(`First parameter (\`value\`) must be of type \`string\` or \`primitive-number\`, but received: \`${getPreciseType(value)}\`, with value: \`${safeStableStringify(value, { keepUndefined: true })}\`.`));
|
|
31
|
+
if (!isPlainObject(options)) options = {};
|
|
32
|
+
const decimal = options.decimal ?? false;
|
|
33
|
+
const totalDecimal = options.totalDecimal ?? 2;
|
|
34
|
+
const endDecimal = options.endDecimal ?? true;
|
|
35
|
+
const indianFormat = options.indianFormat ?? false;
|
|
36
|
+
const suffixCurrency = options.suffixCurrency ?? "";
|
|
37
|
+
const suffixDecimal = options.suffixDecimal ?? "";
|
|
38
|
+
const roundedDecimal = options.roundedDecimal ?? "round";
|
|
39
|
+
const negativeFormat = options.negativeFormat ?? "dash";
|
|
40
|
+
let separatorDecimals = options.separatorDecimals ?? ",";
|
|
41
|
+
let separator = options.separator ?? ".";
|
|
42
|
+
if (!isString(separator) || !isString(separatorDecimals) || !isString(suffixCurrency) || !isString(suffixDecimal)) throw new TypeError(errorMsg$4(`Parameter \`separator\`, \`separatorDecimals\`, \`suffixCurrency\` and \`suffixDecimal\` property of the \`options\` (second parameter) must be of type \`string\`, but received: ['separator': \`${getPreciseType(separator)}\`, 'separatorDecimals': \`${getPreciseType(separatorDecimals)}\`, 'suffixCurrency': \`${getPreciseType(suffixCurrency)}\`, 'suffixDecimal': \`${getPreciseType(suffixDecimal)}\`].`));
|
|
43
|
+
if (!isBoolean(decimal) || !isBoolean(endDecimal) || !isBoolean(indianFormat)) throw new TypeError(errorMsg$4(`Parameter \`decimal\`, \`endDecimal\` and \`indianFormat\` property of the \`options\` (second parameter) must be of type \`boolean\`, but received: ['decimal': \`${getPreciseType(decimal)}\`, 'endDecimal': \`${getPreciseType(endDecimal)}\`, 'indianFormat': \`${getPreciseType(indianFormat)}\`].`));
|
|
44
|
+
if (!isInteger(totalDecimal)) throw new TypeError(errorMsg$4(`Parameter \`totalDecimal\` property of the \`options\` (second parameter) must be of type \`integer-number\`, but received: \`${getPreciseType(totalDecimal)}\`, with value: \`${safeStableStringify(length, { keepUndefined: true })}\`.`));
|
|
45
|
+
if (!(roundedDecimal === false || roundedDecimal === "round" || roundedDecimal === "ceil" || roundedDecimal === "floor")) throw new TypeError(errorMsg$4(`Parameter \`roundedDecimal\` property of the \`options\` (second parameter) must be of type \`false\` or \`string\` must be one of "round" | "ceil" | "floor", but received: \`${getPreciseType(roundedDecimal)}\`, with value: \`${safeStableStringify(roundedDecimal, { keepUndefined: true })}\`.`));
|
|
46
|
+
if (!(negativeFormat === "abs" || negativeFormat === "brackets" || negativeFormat === "dash" || isPlainObject(negativeFormat))) throw new TypeError(errorMsg$4(`Parameter \`negativeFormat\` property of the \`options\` (second parameter) must be of type \`string\` must be one of "abs" | "brackets" | "dash" or \`plain-object\` type, but received: \`${getPreciseType(negativeFormat)}\`, with value: \`${safeStableStringify(negativeFormat, { keepUndefined: true })}\`.`));
|
|
45
47
|
const rawNum = isString(value) ? parseCurrencyString(value) : value;
|
|
46
48
|
if (isNaN(rawNum)) throw new TypeError("First parameter (`value`) could not be parsed into a valid `number`.");
|
|
47
49
|
let integerPart;
|
|
@@ -89,15 +91,15 @@ const formatCurrency = (value, options = {}) => {
|
|
|
89
91
|
else if (negativeFormat === "brackets") formattedInteger = "(" + formattedInteger + ")";
|
|
90
92
|
else if (negativeFormat === "abs") {} else if (isPlainObject(negativeFormat)) if (hasOwnProp(negativeFormat, "custom")) {
|
|
91
93
|
const formatCustomNegative = negativeFormat.custom;
|
|
92
|
-
if (!isFunction(formatCustomNegative)) throw new TypeError(`Parameter \`negativeFormat.custom\` property of the \`options\` (second parameter) must be of type function: \`(formatted: string) => string\`, but received: \`${getPreciseType(formatCustomNegative)}\`.`);
|
|
94
|
+
if (!isFunction(formatCustomNegative)) throw new TypeError(errorMsg$4(`Parameter \`negativeFormat.custom\` property of the \`options\` (second parameter) must be of type function: \`(formatted: string) => string\`, but received: \`${getPreciseType(formatCustomNegative)}\`.`));
|
|
93
95
|
const result = formatCustomNegative(formattedInteger);
|
|
94
|
-
assertIsString(result, { message: ({ currentType, validType }) => `Parameter \`negativeFormat.custom\` property of the \`options\` (second parameter) expected return a \`${validType}\` type value, but received: \`${currentType}\`.` });
|
|
96
|
+
assertIsString(result, { message: ({ currentType, validType }) => errorMsg$4(`Parameter \`negativeFormat.custom\` property of the \`options\` (second parameter) expected return a \`${validType}\` type value, but received: \`${currentType}\`.`) });
|
|
95
97
|
formattedInteger = result;
|
|
96
98
|
} else {
|
|
97
99
|
const formatStyleNegative = negativeFormat.style || "dash";
|
|
98
100
|
const formatSpaceNegative = !isUndefined(negativeFormat.space) ? negativeFormat.space : false;
|
|
99
|
-
assertIsBoolean(formatSpaceNegative, { message: ({ currentType, validType }) => `Parameter \`negativeFormat.space\` property of the \`options\` (second parameter) must be of type \`${validType} or undefined\`, but received: \`${currentType}\`.` });
|
|
100
|
-
if (!(formatStyleNegative === "abs" || formatStyleNegative === "brackets" || formatStyleNegative === "dash")) throw new TypeError(`Parameter \`negativeFormat.style\` property of the \`options\` (second parameter) must be of type \`string\` must be of type "abs" | "brackets" | "dash", but received: \`${getPreciseType(formatStyleNegative)}\`, with value: \`${safeStableStringify(formatStyleNegative, { keepUndefined: true })}\`.`);
|
|
101
|
+
assertIsBoolean(formatSpaceNegative, { message: ({ currentType, validType }) => errorMsg$4(`Parameter \`negativeFormat.space\` property of the \`options\` (second parameter) must be of type \`${validType} or undefined\`, but received: \`${currentType}\`.`) });
|
|
102
|
+
if (!(formatStyleNegative === "abs" || formatStyleNegative === "brackets" || formatStyleNegative === "dash")) throw new TypeError(errorMsg$4(`Parameter \`negativeFormat.style\` property of the \`options\` (second parameter) must be of type \`string\` must be of type "abs" | "brackets" | "dash", but received: \`${getPreciseType(formatStyleNegative)}\`, with value: \`${safeStableStringify(formatStyleNegative, { keepUndefined: true })}\`.`));
|
|
101
103
|
switch (formatStyleNegative) {
|
|
102
104
|
case "dash":
|
|
103
105
|
formattedInteger = "-" + (formatSpaceNegative ? " " : "") + formattedInteger;
|
|
@@ -111,9 +113,10 @@ const formatCurrency = (value, options = {}) => {
|
|
|
111
113
|
}
|
|
112
114
|
return formattedInteger;
|
|
113
115
|
};
|
|
116
|
+
const errorMsg$4 = (msg) => createMessage("formatCurrency", msg);
|
|
114
117
|
const formatNumber = (value, separator = ",") => {
|
|
115
|
-
if (!isString(value) && !isFinite(value)) throw new TypeError(`First parameter (\`value\`) must be of type \`string\` or \`primitive number\`, but received: \`${getPreciseType(value)}\`.`);
|
|
116
|
-
if (!isString(separator)) throw new TypeError(`Second parameter (\`separator\`) must be of type \`string\` or empty as \`undefined\`, but received: \`${getPreciseType(separator)}\`.`);
|
|
118
|
+
if (!isString(value) && !isFinite(value)) throw new TypeError(errorMsg$3(`First parameter (\`value\`) must be of type \`string\` or \`primitive number\`, but received: \`${getPreciseType(value)}\`.`));
|
|
119
|
+
if (!isString(separator)) throw new TypeError(errorMsg$3(`Second parameter (\`separator\`) must be of type \`string\` or empty as \`undefined\`, but received: \`${getPreciseType(separator)}\`.`));
|
|
117
120
|
separator = isString(separator) ? separator : ",";
|
|
118
121
|
const decimalSeparator = separator === "." ? "," : separator === "," ? "." : ".";
|
|
119
122
|
const stringValue = value.toString().trim();
|
|
@@ -133,6 +136,7 @@ const formatNumber = (value, separator = ",") => {
|
|
|
133
136
|
const formattedInteger = integerPart.replace(/\B(?=(\d{3})+(?!\d))/g, separator);
|
|
134
137
|
return decimalPart ? `${formattedInteger}${decimalSeparator}${decimalPart}` : formattedInteger;
|
|
135
138
|
};
|
|
139
|
+
const errorMsg$3 = (msg) => createMessage("formatNumber", msg);
|
|
136
140
|
const parsingAsYouType = (value, defaultCountry) => {
|
|
137
141
|
let parsed;
|
|
138
142
|
try {
|
|
@@ -147,27 +151,27 @@ const parsingAsYouType = (value, defaultCountry) => {
|
|
|
147
151
|
const isValidParseAsYouType = (parsedAsYouType) => {
|
|
148
152
|
return !!parsedAsYouType?.isValid() && !!parsedAsYouType.getNumber();
|
|
149
153
|
};
|
|
150
|
-
function formatPhoneNumber(value, options
|
|
154
|
+
function formatPhoneNumber(value, options) {
|
|
151
155
|
if (isNil(value)) return "";
|
|
152
|
-
if (!isString(value) && !isNumber(value)) throw new TypeError(`First parameter (\`value\`) must be of type \`string\`, \`number\`, \`null\` or \`undefined\`, but received: \`${getPreciseType(value)}\`.`);
|
|
153
|
-
|
|
154
|
-
const takeNumberOnly =
|
|
155
|
-
const checkValidOnly =
|
|
156
|
-
const defaultCountry =
|
|
157
|
-
const separator =
|
|
158
|
-
const prependPlusCountryCode =
|
|
159
|
-
const outputFormat =
|
|
160
|
-
const openingNumberCountry =
|
|
161
|
-
const closingNumberCountry =
|
|
162
|
-
if (!isBoolean(takeNumberOnly) || !isBoolean(checkValidOnly) || !isBoolean(prependPlusCountryCode)) throw new TypeError(`Parameter \`takeNumberOnly\`, \`checkValidOnly\` and \`prependPlusCountryCode\` property of the \`options\` (second parameter) must be of type \`boolean\` or unset as \`undefined\` value, but received: ['takeNumberOnly': \`${getPreciseType(takeNumberOnly)}\`, 'checkValidOnly': \`${getPreciseType(checkValidOnly)}\`, 'prependPlusCountryCode': \`${getPreciseType(prependPlusCountryCode)}\`].`);
|
|
163
|
-
if (!isUndefined(defaultCountry) && !isSupportedCountry(defaultCountry)) throw new TypeError(`Parameter \`defaultCountry\` property of the \`options\` (second parameter) must be of type \`string\` as \`CountryCode\` (ISO-3166-1 alpha-2) or unset as \`undefined\` value, but received: \`${getPreciseType(defaultCountry)}\`, with value: \`${safeStableStringify(defaultCountry, { keepUndefined: true })}\`.\n\nSee: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements, for all ISO 3166-1 alpha-2 code.`);
|
|
156
|
+
if (!isString(value) && !isNumber(value)) throw new TypeError(errorMsg$2(`First parameter (\`value\`) must be of type \`string\`, \`number\`, \`null\` or \`undefined\`, but received: \`${getPreciseType(value)}\`.`));
|
|
157
|
+
if (!isPlainObject(options)) options = {};
|
|
158
|
+
const takeNumberOnly = options.takeNumberOnly ?? false;
|
|
159
|
+
const checkValidOnly = options.checkValidOnly ?? false;
|
|
160
|
+
const defaultCountry = options.defaultCountry ?? void 0;
|
|
161
|
+
const separator = options.separator ?? " ";
|
|
162
|
+
const prependPlusCountryCode = options.prependPlusCountryCode ?? true;
|
|
163
|
+
const outputFormat = options.outputFormat ?? "INTERNATIONAL";
|
|
164
|
+
const openingNumberCountry = options.openingNumberCountry ?? "";
|
|
165
|
+
const closingNumberCountry = options.closingNumberCountry ?? "";
|
|
166
|
+
if (!isBoolean(takeNumberOnly) || !isBoolean(checkValidOnly) || !isBoolean(prependPlusCountryCode)) throw new TypeError(errorMsg$2(`Parameter \`takeNumberOnly\`, \`checkValidOnly\` and \`prependPlusCountryCode\` property of the \`options\` (second parameter) must be of type \`boolean\` or unset as \`undefined\` value, but received: ['takeNumberOnly': \`${getPreciseType(takeNumberOnly)}\`, 'checkValidOnly': \`${getPreciseType(checkValidOnly)}\`, 'prependPlusCountryCode': \`${getPreciseType(prependPlusCountryCode)}\`].`));
|
|
167
|
+
if (!isUndefined(defaultCountry) && !isSupportedCountry(defaultCountry)) throw new TypeError(errorMsg$2(`Parameter \`defaultCountry\` property of the \`options\` (second parameter) must be of type \`string\` as \`CountryCode\` (ISO-3166-1 alpha-2) or unset as \`undefined\` value, but received: \`${getPreciseType(defaultCountry)}\`, with value: \`${safeStableStringify(defaultCountry, { keepUndefined: true })}\`.\n\nSee: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements, for all ISO 3166-1 alpha-2 code.`));
|
|
164
168
|
if (![
|
|
165
169
|
"INTERNATIONAL",
|
|
166
170
|
"NATIONAL",
|
|
167
171
|
"RFC3966",
|
|
168
172
|
"E.164"
|
|
169
|
-
].includes(outputFormat)) throw new TypeError(`Parameter \`outputFormat\` property of the \`options\` (second parameter) must be of type \`string\` as \`OutputFormat\` ("NATIONAL" | "INTERNATIONAL" | "E.164" | "RFC3966") or unset as \`undefined\` (default value to: \`INTERNATIONAL\`) value, but received: \`${getPreciseType(outputFormat)}\`, with value: ${safeStableStringify(outputFormat, { keepUndefined: true })}.`);
|
|
170
|
-
if (!isString(separator) || !isString(openingNumberCountry) || !isString(closingNumberCountry)) throw new TypeError(`Parameter \`separator\`, \`plusNumberCountry\`, \`openingNumberCountry\` and \`closingNumberCountry\` property of the \`options\` (second parameter) must be of type \`string\` or unset as \`undefined\` value, but received: ['separator': \`${getPreciseType(separator)}\`,'openingNumberCountry': \`${getPreciseType(openingNumberCountry)}\`, 'closingNumberCountry': \`${getPreciseType(closingNumberCountry)}\`].`);
|
|
173
|
+
].includes(outputFormat)) throw new TypeError(errorMsg$2(`Parameter \`outputFormat\` property of the \`options\` (second parameter) must be of type \`string\` as \`OutputFormat\` ("NATIONAL" | "INTERNATIONAL" | "E.164" | "RFC3966") or unset as \`undefined\` (default value to: \`INTERNATIONAL\`) value, but received: \`${getPreciseType(outputFormat)}\`, with value: ${safeStableStringify(outputFormat, { keepUndefined: true })}.`));
|
|
174
|
+
if (!isString(separator) || !isString(openingNumberCountry) || !isString(closingNumberCountry)) throw new TypeError(errorMsg$2(`Parameter \`separator\`, \`plusNumberCountry\`, \`openingNumberCountry\` and \`closingNumberCountry\` property of the \`options\` (second parameter) must be of type \`string\` or unset as \`undefined\` value, but received: ['separator': \`${getPreciseType(separator)}\`,'openingNumberCountry': \`${getPreciseType(openingNumberCountry)}\`, 'closingNumberCountry': \`${getPreciseType(closingNumberCountry)}\`].`));
|
|
171
175
|
if (!isString(value)) value = String(value);
|
|
172
176
|
const parsedPhoneNumber = parsingAsYouType(value, defaultCountry);
|
|
173
177
|
const validPhoneNumber = isValidParseAsYouType(parsedPhoneNumber);
|
|
@@ -186,6 +190,7 @@ function formatPhoneNumber(value, options = {}) {
|
|
|
186
190
|
if (outputFormat === "NATIONAL") return `${intlNumb.split(" ").join(separator)}`;
|
|
187
191
|
return intlNumb;
|
|
188
192
|
}
|
|
193
|
+
const errorMsg$2 = (msg) => createMessage("formatPhoneNumber", msg);
|
|
189
194
|
const hashSeedGenerate = (mode, email) => {
|
|
190
195
|
const generateSeed = () => {
|
|
191
196
|
let hash = 0;
|
|
@@ -211,11 +216,11 @@ const _censor = (str, minCensor, maxPercentage, hashSeed) => {
|
|
|
211
216
|
for (const index of indexes) strArr[index] = "*";
|
|
212
217
|
return strArr.join("");
|
|
213
218
|
};
|
|
214
|
-
const censorEmail = (email, options
|
|
219
|
+
const censorEmail = (email, options) => {
|
|
215
220
|
if (!isNonEmptyString(email)) return "";
|
|
216
|
-
|
|
217
|
-
const mode =
|
|
218
|
-
if (mode !== "random" && mode !== "fixed") throw new TypeError(`Parameter \`mode\` property of the \`options\` (second parameter) must be one of "fixed" or "random", but received: \`${getPreciseType(mode)}\`, with value: \`${safeStableStringify(mode, { keepUndefined: true })}\`.`);
|
|
221
|
+
if (!isPlainObject(options)) options = {};
|
|
222
|
+
const mode = options.mode ?? "fixed";
|
|
223
|
+
if (mode !== "random" && mode !== "fixed") throw new TypeError(createMessage("censorEmail", `Parameter \`mode\` property of the \`options\` (second parameter) must be one of "fixed" or "random", but received: \`${getPreciseType(mode)}\`, with value: \`${safeStableStringify(mode, { keepUndefined: true })}\`.`));
|
|
219
224
|
if (!/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(email)) return "";
|
|
220
225
|
const [local, domain] = email.split("@");
|
|
221
226
|
const domainParts = domain?.split(".");
|
|
@@ -228,15 +233,15 @@ const censorEmail = (email, options = {}) => {
|
|
|
228
233
|
const domainMinCensor = domainName.length < 4 ? 1 : 2;
|
|
229
234
|
return `${_censor(local, localMinCensor, .6, hashSeed)}@${_censor(domainName, domainMinCensor, .5, hashSeed)}.${tld.length <= 2 ? tld : _censor(tld, 1, .4, hashSeed)}`;
|
|
230
235
|
};
|
|
231
|
-
function chunkString(subject, limiter, options
|
|
236
|
+
function chunkString(subject, limiter, options) {
|
|
232
237
|
if (isNil(subject) || limiter <= 0) return subject;
|
|
233
|
-
assertIsString(subject, { message: ({ currentType, validType }) => `First parameter (\`subject\`) must be of type \`${validType}\`, but received: \`${currentType}\`.` });
|
|
234
|
-
if (!isInteger(limiter)) throw new TypeError(`Second parameter (\`limiter\`) must be of type \`integer-number\`, but received: \`${getPreciseType(limiter)}\`, with value: \`${safeStableStringify(limiter, { keepUndefined: true })}\`.`);
|
|
235
|
-
|
|
236
|
-
const separator =
|
|
237
|
-
const reCountAfterSpace =
|
|
238
|
-
assertIsString(separator, { message: ({ currentType, validType }) => `Parameter \`separator\` property of the \`options\` (third parameter) must be of type \`${validType}\`, but received: \`${currentType}\`.` });
|
|
239
|
-
assertIsBoolean(reCountAfterSpace, { message: ({ currentType, validType }) => `Parameter \`reCountAfterSpace\` property of the \`options\` (third parameter) must be of type \`${validType}\`, but received: \`${currentType}\`.` });
|
|
238
|
+
assertIsString(subject, { message: ({ currentType, validType }) => errorMsg$1(`First parameter (\`subject\`) must be of type \`${validType}\`, but received: \`${currentType}\`.`) });
|
|
239
|
+
if (!isInteger(limiter)) throw new TypeError(errorMsg$1(`Second parameter (\`limiter\`) must be of type \`integer-number\`, but received: \`${getPreciseType(limiter)}\`, with value: \`${safeStableStringify(limiter, { keepUndefined: true })}\`.`));
|
|
240
|
+
if (!isPlainObject(options)) options = {};
|
|
241
|
+
const separator = options.separator ?? " ";
|
|
242
|
+
const reCountAfterSpace = options.reCountAfterSpace ?? false;
|
|
243
|
+
assertIsString(separator, { message: ({ currentType, validType }) => errorMsg$1(`Parameter \`separator\` property of the \`options\` (third parameter) must be of type \`${validType}\`, but received: \`${currentType}\`.`) });
|
|
244
|
+
assertIsBoolean(reCountAfterSpace, { message: ({ currentType, validType }) => errorMsg$1(`Parameter \`reCountAfterSpace\` property of the \`options\` (third parameter) must be of type \`${validType}\`, but received: \`${currentType}\`.`) });
|
|
240
245
|
subject = normalizeSpaces(subject);
|
|
241
246
|
if (!reCountAfterSpace) {
|
|
242
247
|
let result = "";
|
|
@@ -278,16 +283,17 @@ function chunkString(subject, limiter, options = {}) {
|
|
|
278
283
|
}
|
|
279
284
|
return finalSegments.join(" ");
|
|
280
285
|
}
|
|
281
|
-
const
|
|
286
|
+
const errorMsg$1 = (msg) => createMessage("chunkString", msg);
|
|
287
|
+
const truncateString = (text, options) => {
|
|
282
288
|
if (!isNonEmptyString(text)) return "";
|
|
283
|
-
|
|
284
|
-
const trim =
|
|
285
|
-
const length =
|
|
286
|
-
let ending =
|
|
287
|
-
if (!isInteger(length)) throw new TypeError(`Parameter \`length\` property of the \`options\` (second parameter) must be of type \`integer-number\`, but received: \`${getPreciseType(length)}\`, with value: \`${safeStableStringify(length, { keepUndefined: true })}\`.`);
|
|
289
|
+
if (!isPlainObject(options)) options = {};
|
|
290
|
+
const trim = options.trim ?? true;
|
|
291
|
+
const length = options.length ?? 10;
|
|
292
|
+
let ending = options.ending ?? "...";
|
|
293
|
+
if (!isInteger(length)) throw new TypeError(errorMsg(`Parameter \`length\` property of the \`options\` (second parameter) must be of type \`integer-number\`, but received: \`${getPreciseType(length)}\`, with value: \`${safeStableStringify(length, { keepUndefined: true })}\`.`));
|
|
288
294
|
if (length < 1) return "";
|
|
289
|
-
assertIsString(ending, { message: ({ currentType, validType }) => `Parameter \`ending\` property of the \`options\` (second parameter) must be of type \`${validType}\`, but received: \`${currentType}\`.` });
|
|
290
|
-
assertIsBoolean(trim, { message: ({ currentType, validType }) => `Parameter \`trim\` property of the \`options\` (second parameter) must be of type \`${validType}\`, but received: \`${currentType}\`.` });
|
|
295
|
+
assertIsString(ending, { message: ({ currentType, validType }) => errorMsg(`Parameter \`ending\` property of the \`options\` (second parameter) must be of type \`${validType}\`, but received: \`${currentType}\`.`) });
|
|
296
|
+
assertIsBoolean(trim, { message: ({ currentType, validType }) => errorMsg(`Parameter \`trim\` property of the \`options\` (second parameter) must be of type \`${validType}\`, but received: \`${currentType}\`.`) });
|
|
291
297
|
if (isEmptyString(ending)) ending = "...";
|
|
292
298
|
else ending = ending.trim();
|
|
293
299
|
const original = trim ? text.trim() : text;
|
|
@@ -295,11 +301,12 @@ const truncateString = (text, options = {}) => {
|
|
|
295
301
|
const sliced = original.slice(0, length);
|
|
296
302
|
return (trim ? sliced : sliced.trimEnd()) + ending;
|
|
297
303
|
};
|
|
304
|
+
const errorMsg = (msg) => createMessage("truncateString", msg);
|
|
298
305
|
const formatDateFns = (date, options = {}) => {
|
|
299
306
|
if (isNil(date) || !(isDate(date) || isNonEmptyString(date))) return null;
|
|
300
307
|
if (!isPlainObject(options)) options = {};
|
|
301
308
|
const { inputFormat, locale = "en", inputLocale = "en", ...restOptions } = options;
|
|
302
|
-
const format$1 =
|
|
309
|
+
const format$1 = options.format ?? "dd MMM yyyy - HH:mm:ss";
|
|
303
310
|
let parsedDate;
|
|
304
311
|
try {
|
|
305
312
|
if (isNonEmptyString(date) && inputFormat && inputLocale) {
|
|
@@ -328,7 +335,7 @@ const formatDateIntl = (date, options) => {
|
|
|
328
335
|
return null;
|
|
329
336
|
}
|
|
330
337
|
};
|
|
331
|
-
const formatDateTime = (date, format) => {
|
|
338
|
+
const formatDateTime = (date, format = "YYYY-MM-DD hh:mm:ss") => {
|
|
332
339
|
if (isNil(format)) format = "YYYY-MM-DD hh:mm:ss";
|
|
333
340
|
if (!isString(format)) return null;
|
|
334
341
|
if (isNil(date) || !(isDate(date) || isNonEmptyString(date))) return null;
|
|
@@ -366,4 +373,4 @@ const getGMTOffset = (date) => {
|
|
|
366
373
|
}
|
|
367
374
|
};
|
|
368
375
|
export { truncateString as a, formatPhoneNumber as c, formatDateFns as i, formatNumber as l, formatDateTime as n, chunkString as o, formatDateIntl as r, censorEmail as s, getGMTOffset as t, formatCurrency as u };
|
|
369
|
-
//# sourceMappingURL=formatters-
|
|
376
|
+
//# sourceMappingURL=formatters-BAbGsnYA.js.map
|