@rzl-zone/utils-js 3.13.1 → 3.14.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-CgE6QNOR.js +20 -0
- package/dist/AbortError-CgE6QNOR.js.map +1 -0
- package/dist/AbortError-D54txsmn.cjs +26 -0
- package/dist/AbortError-D54txsmn.cjs.map +1 -0
- package/dist/{assertIsArray-HgzPQIAM.js → assertIsArray-DmlqnTiq.js} +3 -3
- package/dist/assertIsArray-DmlqnTiq.js.map +1 -0
- package/dist/{assertIsArray-CeXL4xv5.cjs → assertIsArray-Xx-zlo6O.cjs} +5 -5
- package/dist/assertIsArray-Xx-zlo6O.cjs.map +1 -0
- package/dist/assertIsPlainObject-CIzDchLs.js +20 -0
- package/dist/assertIsPlainObject-CIzDchLs.js.map +1 -0
- package/dist/assertIsPlainObject-DYoxHcW5.cjs +26 -0
- package/dist/assertIsPlainObject-DYoxHcW5.cjs.map +1 -0
- package/dist/{assertIsString-DUrVt82d.cjs → assertIsString-CuPbh3FB.cjs} +6 -6
- package/dist/assertIsString-CuPbh3FB.cjs.map +1 -0
- package/dist/{assertIsString-CY_WkCLr.js → assertIsString-sgY3ml5f.js} +4 -4
- package/dist/assertIsString-sgY3ml5f.js.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-1s7xMBe_.js → conversions-BkxqYXxy.js} +43 -40
- package/dist/conversions-BkxqYXxy.js.map +1 -0
- package/dist/conversions-UdMB90xR.cjs +449 -0
- package/dist/conversions-UdMB90xR.cjs.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-BFgV1HhV-BtIJs2H2.js +55 -0
- package/dist/formatter-BFgV1HhV-BtIJs2H2.js.map +1 -0
- package/dist/formatter-BFgV1HhV-DyybWSuj.cjs +67 -0
- package/dist/formatter-BFgV1HhV-DyybWSuj.cjs.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-Cjng28nY.cjs +436 -0
- package/dist/formatters-Cjng28nY.cjs.map +1 -0
- package/dist/{formatters-C6cVZBbG.js → formatters-Dqccnt-p.js} +78 -71
- package/dist/formatters-Dqccnt-p.js.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-DTWYqy7S.cjs +53 -0
- package/dist/hasOwnProp-DTWYqy7S.cjs.map +1 -0
- package/dist/hasOwnProp-yVVsxPin.js +47 -0
- package/dist/hasOwnProp-yVVsxPin.js.map +1 -0
- package/dist/{index-BG8wdusZ.d.cts → index-9Ql1W3gt.d.cts} +229 -200
- package/dist/{index-RNQBTK8A.d.cts → index-BD0J8wkE.d.cts} +1374 -936
- package/dist/index-BcoUy2oV.d.ts +2424 -0
- package/dist/{index-B5EBAgmC.d.cts → index-Bpk3YwGW.d.ts} +1592 -790
- package/dist/index-CTMG8cZV.d.ts +1041 -0
- package/dist/index-DUBCXPy4.d.cts +1041 -0
- package/dist/{index-CRz9rSZL.d.ts → index-DhUTzQ_o.d.ts} +1374 -936
- package/dist/{index-B1VQ6USF.d.ts → index-DqYMKSmd.d.ts} +229 -200
- package/dist/index-JfwSupYB.d.ts +1103 -0
- package/dist/{index-ORbo-7zA.d.cts → index-O2q2f-pu.d.cts} +242 -133
- package/dist/{index-DPJ-e2JZ.d.ts → index-VgNZ6ndx.d.cts} +1592 -790
- package/dist/{index-ORbo-7zA.d.ts → index-k_rjVRjU.d.ts} +242 -133
- package/dist/index-or0oP9i2.d.cts +2179 -0
- package/dist/index-or0oP9i2.d.ts +2179 -0
- package/dist/index-u4-Euidh.d.cts +1103 -0
- package/dist/index-zAqCZxGr.d.cts +2424 -0
- package/dist/{isBigInt-y7s3rsKc.js → isBigInt-DdFRCpeE.js} +2 -2
- package/dist/isBigInt-DdFRCpeE.js.map +1 -0
- package/dist/{isBigInt-BVj0M5pq.cjs → isBigInt-LkCpVJ3E.cjs} +2 -2
- package/dist/isBigInt-LkCpVJ3E.cjs.map +1 -0
- package/dist/{isEmptyString-BYMz_wt9.js → isEmptyString-B6ubItgT.js} +4 -4
- package/dist/isEmptyString-B6ubItgT.js.map +1 -0
- package/dist/{isEmptyString-C8PYNPgw.cjs → isEmptyString-Csc5Sf_W.cjs} +5 -5
- package/dist/isEmptyString-Csc5Sf_W.cjs.map +1 -0
- package/dist/isEmptyValue-h97JT4pD.js +36 -0
- package/dist/isEmptyValue-h97JT4pD.js.map +1 -0
- package/dist/isEmptyValue-qNOhUBFE.cjs +54 -0
- package/dist/isEmptyValue-qNOhUBFE.cjs.map +1 -0
- package/dist/{isFinite-DeDaBDr2.cjs → isFinite-CKeuVXbD.cjs} +6 -6
- package/dist/isFinite-CKeuVXbD.cjs.map +1 -0
- package/dist/{isFinite-BEJFOv6B.js → isFinite-CzYYv-mQ.js} +5 -5
- package/dist/isFinite-CzYYv-mQ.js.map +1 -0
- package/dist/{isInteger-DEDbBGez.js → isInteger-BtA3flbk.js} +4 -4
- package/dist/isInteger-BtA3flbk.js.map +1 -0
- package/dist/{isInteger-CQLThJOR.cjs → isInteger-iTok9NaH.cjs} +4 -4
- package/dist/isInteger-iTok9NaH.cjs.map +1 -0
- package/dist/isNumber-C1mOuBuA.js +20 -0
- package/dist/isNumber-C1mOuBuA.js.map +1 -0
- package/dist/isNumber-CM1vdNcW.cjs +26 -0
- package/dist/isNumber-CM1vdNcW.cjs.map +1 -0
- package/dist/isPlainObject-DQoM4DGQ.d.ts +331 -0
- package/dist/isPlainObject-Y__iykWN.d.cts +331 -0
- package/dist/{isServer-DmycqWsF.cjs → isServer-CWlp2R2N.cjs} +2 -2
- package/dist/isServer-CWlp2R2N.cjs.map +1 -0
- package/dist/{isServer-q3o6cSwD.js → isServer-Drgyboev.js} +2 -2
- package/dist/isServer-Drgyboev.js.map +1 -0
- package/dist/{isEqual-DM4S_kWh.js → isTypedArray-BY8CIj3k.js} +29 -9
- package/dist/isTypedArray-BY8CIj3k.js.map +1 -0
- package/dist/{isEqual-DaPDxMyw.cjs → isTypedArray-DspIjxdk.cjs} +45 -13
- package/dist/isTypedArray-DspIjxdk.cjs.map +1 -0
- package/dist/{isValidDomain-B8Nukgw0.js → isValidDomain-BPfJEkFk.js} +13 -54
- package/dist/isValidDomain-BPfJEkFk.js.map +1 -0
- package/dist/{isValidDomain-ZbyeGOO9.cjs → isValidDomain-DUUCoKtD.cjs} +16 -69
- package/dist/isValidDomain-DUUCoKtD.cjs.map +1 -0
- package/dist/{assertIsBoolean-D41HrTB_.cjs → logger-BXg2xufj.cjs} +658 -612
- package/dist/logger-BXg2xufj.cjs.map +1 -0
- package/dist/{assertIsBoolean-CWUs-I5l.js → logger-Wxl_Krg6.js} +657 -587
- package/dist/logger-Wxl_Krg6.js.map +1 -0
- package/dist/{noop-BY43WaoU.cjs → noop-ByxeOveJ.cjs} +2 -2
- package/dist/noop-ByxeOveJ.cjs.map +1 -0
- package/dist/{noop-CjY8xVHv.js → noop-D8aGbjbP.js} +2 -2
- package/dist/noop-D8aGbjbP.js.map +1 -0
- package/dist/{normalizeSpaces-BhZp0U_6.cjs → normalizeSpaces-CQ7tZLNG.cjs} +6 -9
- package/dist/normalizeSpaces-CQ7tZLNG.cjs.map +1 -0
- package/dist/{normalizeSpaces-BoUDtq5P.js → normalizeSpaces-DNUOxp_8.js} +4 -7
- package/dist/normalizeSpaces-DNUOxp_8.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-B_FPX35n.cjs → parsers-CJ5tHtqF.cjs} +10 -9
- package/dist/parsers-CJ5tHtqF.cjs.map +1 -0
- package/dist/{parsers-B8KYXIjE.js → parsers-DMlqliPw.js} +9 -8
- package/dist/parsers-DMlqliPw.js.map +1 -0
- package/dist/{parsing-BCZGco7n.cjs → parsing-DB_S0WFz.cjs} +4 -4
- package/dist/parsing-DB_S0WFz.cjs.map +1 -0
- package/dist/{parsing-Bfaw85Hd.js → parsing-DhIQhWpX.js} +3 -3
- package/dist/parsing-DhIQhWpX.js.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-KlyOvBSC.js → predicates-BzYMbNrZ.js} +45 -40
- package/dist/predicates-BzYMbNrZ.js.map +1 -0
- package/dist/{predicates-8y28VrbT.cjs → predicates-DDW3etqF.cjs} +89 -84
- package/dist/predicates-DDW3etqF.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-DnKi0qjS.cjs → punyCode-B_VPjG0d.cjs} +12 -12
- package/dist/punyCode-B_VPjG0d.cjs.map +1 -0
- package/dist/{punyCode-Dwto1RpA.js → punyCode-DsuJbWCl.js} +12 -12
- package/dist/punyCode-DsuJbWCl.js.map +1 -0
- package/dist/{removeSpaces--8NW-HSx.js → removeSpaces-BF-T_1Yt.js} +4 -4
- package/dist/removeSpaces-BF-T_1Yt.js.map +1 -0
- package/dist/{removeSpaces-CmrrkeXz.cjs → removeSpaces-BJu-gKps.cjs} +7 -7
- package/dist/removeSpaces-BJu-gKps.cjs.map +1 -0
- package/dist/rzl-utils.global.js +13 -13
- package/dist/safeJsonParse-B5F8XtrZ.cjs +209 -0
- package/dist/safeJsonParse-B5F8XtrZ.cjs.map +1 -0
- package/dist/{safeJsonParse-OnUwG2El.js → safeJsonParse-DYSkUnhM.js} +29 -28
- package/dist/safeJsonParse-DYSkUnhM.js.map +1 -0
- package/dist/{safeStableStringify-B2KTTS3r.js → safeStableStringify-CDSYnLUz.js} +20 -13
- package/dist/safeStableStringify-CDSYnLUz.js.map +1 -0
- package/dist/safeStableStringify-MuBiT-4B.cjs +125 -0
- package/dist/safeStableStringify-MuBiT-4B.cjs.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-CUdmv-oO.js → tailwind-BhHULklj.js} +38 -32
- package/dist/tailwind-BhHULklj.js.map +1 -0
- package/dist/{tailwind-DUuboq52.cjs → tailwind-hx6TIFIL.cjs} +59 -53
- package/dist/tailwind-hx6TIFIL.cjs.map +1 -0
- package/dist/{toStringArrayUnRecursive-OOHGazks.js → toStringArrayUnRecursive-U-nkEIDs.js} +9 -9
- package/dist/toStringArrayUnRecursive-U-nkEIDs.js.map +1 -0
- package/dist/toStringArrayUnRecursive-_lJEmBlf.cjs +51 -0
- package/dist/toStringArrayUnRecursive-_lJEmBlf.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-BXT4Krsq.js → urls-BcGIFgfR.js} +50 -41
- package/dist/urls-BcGIFgfR.js.map +1 -0
- package/dist/urls-DGvZsMSN.cjs +308 -0
- package/dist/urls-DGvZsMSN.cjs.map +1 -0
- package/package.json +6 -6
- package/dist/assertIsArray-CeXL4xv5.cjs.map +0 -1
- package/dist/assertIsArray-HgzPQIAM.js.map +0 -1
- package/dist/assertIsBoolean-CWUs-I5l.js.map +0 -1
- package/dist/assertIsBoolean-D41HrTB_.cjs.map +0 -1
- package/dist/assertIsString-CY_WkCLr.js.map +0 -1
- package/dist/assertIsString-DUrVt82d.cjs.map +0 -1
- package/dist/conversions-1s7xMBe_.js.map +0 -1
- package/dist/conversions-B3Rf8uId.cjs +0 -446
- package/dist/conversions-B3Rf8uId.cjs.map +0 -1
- package/dist/formatters-C6cVZBbG.js.map +0 -1
- package/dist/formatters-aEAAuzjx.cjs +0 -429
- package/dist/formatters-aEAAuzjx.cjs.map +0 -1
- package/dist/index-CPCt6_Wq.d.cts +0 -765
- package/dist/index-CPCt6_Wq.d.ts +0 -765
- package/dist/index-DBwNa1iO.d.ts +0 -947
- package/dist/index-DPTYOQkn.d.cts +0 -947
- package/dist/index-Dig1fIhZ.d.cts +0 -1716
- package/dist/index-Dig1fIhZ.d.ts +0 -1716
- package/dist/isBigInt-BVj0M5pq.cjs.map +0 -1
- package/dist/isBigInt-y7s3rsKc.js.map +0 -1
- package/dist/isEmptyObject-BsHngDz4.cjs +0 -37
- package/dist/isEmptyObject-BsHngDz4.cjs.map +0 -1
- package/dist/isEmptyObject-DPGR9iPj.js +0 -25
- package/dist/isEmptyObject-DPGR9iPj.js.map +0 -1
- package/dist/isEmptyString-BYMz_wt9.js.map +0 -1
- package/dist/isEmptyString-C8PYNPgw.cjs.map +0 -1
- package/dist/isEmptyValue-BXf7f1jz.cjs +0 -30
- package/dist/isEmptyValue-BXf7f1jz.cjs.map +0 -1
- package/dist/isEmptyValue-D4OHTB3u.js +0 -24
- package/dist/isEmptyValue-D4OHTB3u.js.map +0 -1
- package/dist/isEqual-DM4S_kWh.js.map +0 -1
- package/dist/isEqual-DaPDxMyw.cjs.map +0 -1
- package/dist/isFinite-BEJFOv6B.js.map +0 -1
- package/dist/isFinite-DeDaBDr2.cjs.map +0 -1
- package/dist/isInteger-CQLThJOR.cjs.map +0 -1
- package/dist/isInteger-DEDbBGez.js.map +0 -1
- package/dist/isPlainObject-BwTkj3G0.d.cts +0 -339
- package/dist/isPlainObject-BwTkj3G0.d.ts +0 -339
- package/dist/isServer-DmycqWsF.cjs.map +0 -1
- package/dist/isServer-q3o6cSwD.js.map +0 -1
- package/dist/isTypedArray-BQLbLXsU.cjs +0 -43
- package/dist/isTypedArray-BQLbLXsU.cjs.map +0 -1
- package/dist/isTypedArray-XiBnifLN.js +0 -31
- package/dist/isTypedArray-XiBnifLN.js.map +0 -1
- package/dist/isValidDomain-B8Nukgw0.js.map +0 -1
- package/dist/isValidDomain-ZbyeGOO9.cjs.map +0 -1
- package/dist/noop-BY43WaoU.cjs.map +0 -1
- package/dist/noop-CjY8xVHv.js.map +0 -1
- package/dist/normalizeSpaces-BhZp0U_6.cjs.map +0 -1
- package/dist/normalizeSpaces-BoUDtq5P.js.map +0 -1
- package/dist/parsers-B8KYXIjE.js.map +0 -1
- package/dist/parsers-B_FPX35n.cjs.map +0 -1
- package/dist/parsing-BCZGco7n.cjs.map +0 -1
- package/dist/parsing-Bfaw85Hd.js.map +0 -1
- package/dist/predicates-8y28VrbT.cjs.map +0 -1
- package/dist/predicates-KlyOvBSC.js.map +0 -1
- package/dist/punyCode-DnKi0qjS.cjs.map +0 -1
- package/dist/punyCode-Dwto1RpA.js.map +0 -1
- package/dist/removeSpaces--8NW-HSx.js.map +0 -1
- package/dist/removeSpaces-CmrrkeXz.cjs.map +0 -1
- package/dist/safeJsonParse-OnUwG2El.js.map +0 -1
- package/dist/safeJsonParse-sFqVXf-e.cjs +0 -208
- package/dist/safeJsonParse-sFqVXf-e.cjs.map +0 -1
- package/dist/safeStableStringify-B2KTTS3r.js.map +0 -1
- package/dist/safeStableStringify-Cmi6GyWj.cjs +0 -106
- package/dist/safeStableStringify-Cmi6GyWj.cjs.map +0 -1
- package/dist/tailwind-CUdmv-oO.js.map +0 -1
- package/dist/tailwind-DUuboq52.cjs.map +0 -1
- package/dist/toStringArrayUnRecursive-OOHGazks.js.map +0 -1
- package/dist/toStringArrayUnRecursive-pfk2oP8C.cjs +0 -51
- package/dist/toStringArrayUnRecursive-pfk2oP8C.cjs.map +0 -1
- package/dist/urls-BL9C_yU3.cjs +0 -299
- package/dist/urls-BL9C_yU3.cjs.map +0 -1
- package/dist/urls-BXT4Krsq.js.map +0 -1
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
* ========================================================================
|
|
3
3
|
* @rzl-zone/utils-js
|
|
4
4
|
* ------------------------------------------------------------------------
|
|
5
|
-
* Version: `3.
|
|
5
|
+
* Version: `3.14.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 assertIsBigInt, i as assertIsNumber, n as assertIsPlainObject, o as assertIsBoolean, r as assertIsArray, t as assertIsString } from "../index-
|
|
11
|
+
import { a as assertIsBigInt, i as assertIsNumber, n as assertIsPlainObject, o as assertIsBoolean, r as assertIsArray, t as assertIsString } from "../index-DqYMKSmd.js";
|
|
12
12
|
export { assertIsArray, assertIsBigInt, assertIsBoolean, assertIsNumber, assertIsPlainObject, assertIsString };
|
package/dist/assertions/index.js
CHANGED
|
@@ -2,16 +2,18 @@
|
|
|
2
2
|
* ========================================================================
|
|
3
3
|
* @rzl-zone/utils-js
|
|
4
4
|
* ------------------------------------------------------------------------
|
|
5
|
-
* Version: `3.
|
|
5
|
+
* Version: `3.14.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 {
|
|
11
|
-
import { t as isBigInt } from "../isBigInt-
|
|
12
|
-
import { t as
|
|
13
|
-
import { t as
|
|
14
|
-
|
|
10
|
+
import { n as assertIsBoolean, r as resolveErrorMessageAssertions } from "../logger-Wxl_Krg6.js";
|
|
11
|
+
import { t as isBigInt } from "../isBigInt-DdFRCpeE.js";
|
|
12
|
+
import { t as isNumber } from "../isNumber-C1mOuBuA.js";
|
|
13
|
+
import { t as assertIsArray } from "../assertIsArray-DmlqnTiq.js";
|
|
14
|
+
import { t as assertIsPlainObject } from "../assertIsPlainObject-CIzDchLs.js";
|
|
15
|
+
import { t as assertIsString } from "../assertIsString-sgY3ml5f.js";
|
|
16
|
+
const assertIsBigInt = (value, options) => {
|
|
15
17
|
if (isBigInt(value)) return;
|
|
16
18
|
resolveErrorMessageAssertions({
|
|
17
19
|
value,
|
|
@@ -19,8 +21,8 @@ const assertIsBigInt = (value, options = {}) => {
|
|
|
19
21
|
requiredValidType: "bigint"
|
|
20
22
|
});
|
|
21
23
|
};
|
|
22
|
-
const assertIsNumber = (value, options
|
|
23
|
-
if (isNumber(value, { includeNaN:
|
|
24
|
+
const assertIsNumber = (value, options) => {
|
|
25
|
+
if (isNumber(value, { includeNaN: options?.includeNaN ?? void 0 })) return;
|
|
24
26
|
resolveErrorMessageAssertions({
|
|
25
27
|
value,
|
|
26
28
|
options,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/assertions/number/assertIsBigInt.ts","../../src/assertions/number/assertIsNumber.ts"],"sourcesContent":["import { isBigInt } from \"@/predicates/is/isBigInt\";\n\nimport {\n resolveErrorMessageAssertions,\n type OptionsAssertIs\n} from \"../_private/assertIs\";\n\n/** -------------------------------------------------------\n * * ***Type guard assertion: `assertIsBigInt`.***\n * -------------------------------------------------------\n * **This function is an **assertion function**.**\n * - **Behavior:**\n * - Validates that the given `value` is a **bigint**.\n * - After it returns successfully, TypeScript narrows the type of `value` to `bigint`.\n * - ✅ If `value` is a `bigint` ➔ execution continues normally.\n * - ❌ If `value` is not a `bigint` ➔ throws a built-in error with either:\n * - A custom error message (`options.message`), or\n * - A default message including the actual type.\n * - **ℹ️ Note:**\n * - A `bigint` refers strictly to the JavaScript `bigint` primitive type (e.g., `123n`, `0n`, `-999999999999999999999n`).\n * - This excludes `BigInt` objects created with `Object(BigInt(123))`.\n * - **⚠️ Error type selection (`options.errorType`):**\n * - You can override the type of error thrown when validation fails.\n * - Must be one of the standard JavaScript built-in errors:\n * - [`TypeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError) |\n * [`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) |\n * [`EvalError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/EvalError) |\n * [`RangeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RangeError) |\n * [`ReferenceError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ReferenceError) |\n * [`SyntaxError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SyntaxError) |\n * [`URIError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/URIError)\n * - **Default:** `\"TypeError\"` if not provided or invalid.\n * @param {*} value - ***The value to validate.***\n * @param {OptionsAssertIs} [options]\n * ***Optional configuration:***\n * - `message`: A custom error message (`string` or `function`).\n * - `errorType`: Built-in JavaScript error type to throw on failure (default `\"TypeError\"`).\n * - `formatCase`: Controls how detected type names are formatted case in error messages.\n * - `useAcronyms`: Control uppercase preservation of recognized acronyms during formatting.\n * @returns {boolean} Narrows `value` to `bigint` if no error is thrown.\n * @throws [`TypeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError) | [`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) | [`EvalError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/EvalError) | [`RangeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RangeError) | [`ReferenceError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ReferenceError) | [`SyntaxError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SyntaxError) | [`URIError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/URIError) if the value is not a bigint.\n * @example\n * ```ts\n * // ✅ Simple usage\n * assertIsBigInt(123n);\n * // No error, value is bigint\n *\n * // ❌ Throws TypeError (default behavior)\n * assertIsBigInt(42);\n * // ➔ TypeError: \"Parameter input (`value`) must be of type `bigint`, but received: `number`.\"\n *\n * // ❌ Throws a TypeError with a custom string static message\n * assertIsBigInt(\"123\", { message: \"Must be a bigint!\" });\n * // ➔ TypeError: \"Must be a bigint!\"\n *\n * // ❌ Throws custom error type (e.g., RangeError)\n * assertIsBigInt(async function () {}, { errorType: \"RangeError\" });\n * // ➔ RangeError: \"Parameter input (`value`) must be of type `bigint`, but received: `async-function`.\"\n *\n * // ❌ Throws a TypeError with a custom message function and formatCase\n * assertIsBigInt(/regex/, {\n * message: ({ currentType, validType }) => {\n * return `Expected ${validType} but got (${currentType}).`\n * },\n * formatCase: \"toPascalCaseSpace\"\n * });\n * // ➔ TypeError: \"Expected bigint but got (Reg Exp).\"\n *\n * // ❌ Throws a TypeError with a custom useAcronyms option\n * // Case 1:\n * assertIsBigInt(new URL(\"https://example.com\"),{\n * message: ({ currentType, validType }) => {\n * return `Expected ${validType} but got (${currentType}).`\n * },\n * });\n * // ➔ TypeError: \"Expected bigint but got (url).\"\n * assertIsBigInt(new URL(\"https://example.com\"), {\n * useAcronyms: true,\n * message: ({ currentType, validType }) => {\n * return `Expected ${validType} but got (${currentType}).`\n * },\n * });\n * // ➔ TypeError: \"Expected bigint but got (URL).\"\n *\n * // Case 2:\n * assertIsBigInt(new URLSearchParams, {\n * formatCase: \"toPascalCase\",\n * message: ({ currentType, validType }) => {\n * return `Expected ${validType} but got (${currentType}).`\n * },\n * });\n * // ➔ TypeError: \"Expected bigint but got (UrlSearchParams).\"\n * assertIsBigInt(new URLSearchParams, {\n * useAcronyms: true,\n * formatCase: \"toPascalCase\",\n * message: ({ currentType, validType }) => {\n * return `Expected ${validType} but got (${currentType}).`\n * },\n * });\n * // ➔ TypeError: \"Expected bigint but got (URLSearchParams).\"\n * ```\n * -------------------------------------------------------\n * ✅ ***Real-world usage example***:\n * ```ts\n * const mixedValue: string | bigint | undefined = getUserInput();\n *\n * // Runtime assertion: throws if `mixedValue` is not a `bigint`\n * assertIsBigInt(mixedValue, {\n * errorType: \"RangeError\",\n * message: \"Must be bigint!\"\n * });\n *\n * // ✅ If no error thrown, TypeScript narrows `mixedValue` to `bigint` here\n * const result: bigint = mixedValue; // ➔ Safe type assignment\n * console.log(result + 100n); // ➔ Safe to operation\n * ```\n */\nexport const assertIsBigInt: (\n value: unknown,\n options?: OptionsAssertIs\n) => asserts value is bigint = (\n value: unknown,\n options: OptionsAssertIs = {}\n): asserts value is bigint => {\n if (isBigInt(value)) return;\n\n resolveErrorMessageAssertions({\n value,\n options,\n requiredValidType: \"bigint\"\n });\n};\n","import { isNumber, type IsNumberOptions } from \"@/predicates/is/isNumber\";\n\nimport {\n resolveErrorMessageAssertions,\n type OptionsAssertIs\n} from \"../_private/assertIs\";\nimport { hasOwnProp } from \"@/predicates/has/hasOwnProp\";\n\ntype OptionsAssertIsNumber = OptionsAssertIs & IsNumberOptions;\n\n/** -------------------------------------------------------\n * * ***Type guard assertion: `assertIsNumber`.***\n * -------------------------------------------------------\n * **This function is an **assertion function**.**\n * - **Behavior:**\n * - Validates that the given `value` is a **number**.\n * - After it returns successfully, TypeScript narrows the type of `value` to `number`.\n * - ✅ If `value` is a `number` ➔ execution continues normally.\n * - ❌ If `value` is not a `number` ➔ throws a built-in error with either:\n * - A custom error message (`options.message`), or\n * - A default message including the actual type.\n * - **ℹ️ Note:**\n * - A `number` refers strictly to the JavaScript `number` primitive type (e.g., `42`, `3.14`, `-1`, `0`).\n * - This excludes `Number` objects created with `new Number(123)`.\n * - By default, `NaN` is **not considered** valid, you can allow it with `{ includeNaN: true }`.\n * - **⚠️ Error type selection (`options.errorType`):**\n * - You can override the type of error thrown when validation fails.\n * - Must be one of the standard JavaScript built-in errors:\n * - [`TypeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError) |\n * [`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) |\n * [`EvalError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/EvalError) |\n * [`RangeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RangeError) |\n * [`ReferenceError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ReferenceError) |\n * [`SyntaxError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SyntaxError) |\n * [`URIError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/URIError)\n * - **Default:** `\"TypeError\"` if not provided or invalid.\n * @param {*} value - ***The value to validate.***\n * @param {OptionsAssertIsNumber} [options]\n * ***Optional configuration:***\n * - `message`: A custom error message (`string` or `function`).\n * - `errorType`: Built-in JavaScript error type to throw on failure (default `\"TypeError\"`).\n * - `formatCase`: Controls how detected type names are formatted case in error messages.\n * - `useAcronyms`: Control uppercase preservation of recognized acronyms during formatting.\n * - `includeNaN`: Whether to treat `NaN` as valid.\n * @returns {boolean} Narrows `value` to `number` if no error is thrown.\n * @throws [`TypeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError) | [`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) | [`EvalError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/EvalError) | [`RangeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RangeError) | [`ReferenceError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ReferenceError) | [`SyntaxError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SyntaxError) | [`URIError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/URIError) if the value is not a number (or is `NaN` when `includeNaN` is `false`).\n * @example\n * ```ts\n * // ✅ Simple usage\n * assertIsNumber(123);\n * assertIsNumber(NaN, { includeNaN: true });\n * // No error, value is number\n *\n * // ❌ Throws TypeError (default behavior)\n * // Case 1: Invalid input type — received a string instead of a number\n * assertIsNumber(\"42\");\n * // ➔ TypeError: \"Parameter input (`value`) must be of type `number`, but received: `string`.\"\n *\n * // Case 2: Default option includeNaN is false\n * assertIsNumber(NaN);\n * // ➔ TypeError: \"Parameter input (`value`) must be of type `number`, but received: `NaN`.\"\n *\n * // Case 3: The new Number() is a Number object (constructor), not a primitive number\n * assertIsNumber(new Number(\"123\"));\n * // ➔ TypeError: \"Parameter input (`value`) must be of type `number`, but received: `number-constructor`.\"\n *\n * // ❌ Throws custom error type (e.g., RangeError)\n * assertIsNumber(async function () {}, { errorType: \"RangeError\" });\n * // ➔ RangeError: \"Parameter input (`value`) must be of type `number`, but received: `async-function`.\"\n *\n * // ❌ Throws a TypeError with a custom string static message\n * assertIsNumber(\"123\", { message: \"Must be a number!\" });\n * // ➔ TypeError: \"Must be a number!\"\n *\n * // ❌ Throws a TypeError with a custom message function and formatCase\n * assertIsNumber(/regex/, {\n * message: ({ currentType, validType }) => {\n * return `Expected ${validType} but got (${currentType}).`\n * },\n * formatCase: \"toPascalCaseSpace\"\n * });\n * // ➔ TypeError: \"Expected number but got (Reg Exp).\"\n *\n * // ❌ Throws a TypeError with a custom useAcronyms option\n * // Case 1:\n * assertIsNumber(new URL(\"https://example.com\"),{\n * message: ({ currentType, validType }) => {\n * return `Expected ${validType} but got (${currentType}).`\n * },\n * });\n * // ➔ TypeError: \"Expected number but got (url).\"\n * assertIsNumber(new URL(\"https://example.com\"), {\n * useAcronyms: true,\n * message: ({ currentType, validType }) => {\n * return `Expected ${validType} but got (${currentType}).`\n * },\n * });\n * // ➔ TypeError: \"Expected number but got (URL).\"\n *\n * // Case 2:\n * assertIsNumber(new URLSearchParams, {\n * formatCase: \"toPascalCase\",\n * message: ({ currentType, validType }) => {\n * return `Expected ${validType} but got (${currentType}).`\n * },\n * });\n * // ➔ TypeError: \"Expected number but got (UrlSearchParams).\"\n * assertIsNumber(new URLSearchParams, {\n * useAcronyms: true,\n * formatCase: \"toPascalCase\",\n * message: ({ currentType, validType }) => {\n * return `Expected ${validType} but got (${currentType}).`\n * },\n * });\n * // ➔ TypeError: \"Expected number but got (URLSearchParams).\"\n * ```\n * -------------------------------------------------------\n * ✅ ***Real-world usage example***:\n * ```ts\n * const mixedValue: string | number | undefined = getUserInput();\n *\n * // Runtime assertion: throws if `mixedValue` is not a `number`\n * assertIsNumber(mixedValue, {\n * errorType: \"RangeError\",\n * message: \"Must be number!\"\n * });\n *\n * // ✅ If no error thrown, TypeScript narrows `mixedValue` to `number` here\n * const result: number = mixedValue; // ➔ Safe type assignment\n * console.log(result + 100); // ➔ Safe to operation\n * ```\n */\nexport const assertIsNumber: (\n value: unknown,\n options?: OptionsAssertIsNumber\n) => asserts value is number = (\n value: unknown,\n options: OptionsAssertIsNumber = {}\n): asserts value is number => {\n const includeNaN = hasOwnProp(options, \"includeNaN\")\n ? options.includeNaN\n : undefined;\n\n if (isNumber(value, { includeNaN })) return;\n\n resolveErrorMessageAssertions({\n value,\n options,\n requiredValidType: \"number\"\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqHA,MAAa,kBAIX,OACA,UAA2B,CAAC,MACA;CAC5B,IAAI,SAAS,KAAK,GAAG;CAErB,8BAA8B;EAC5B;EACA;EACA,mBAAmB;CACrB,CAAC;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACCA,MAAa,kBAIX,OACA,UAAiC,CAAC,MACN;CAK5B,IAAI,SAAS,OAAO,EAAE,YAJH,WAAW,SAAS,YAAY,IAC/C,QAAQ,aACR,OAE6B,CAAC,GAAG;CAErC,8BAA8B;EAC5B;EACA;EACA,mBAAmB;CACrB,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/assertions/number/assertIsBigInt.ts","../../src/assertions/number/assertIsNumber.ts"],"sourcesContent":["import { isBigInt } from \"@/predicates/is/isBigInt\";\n\nimport {\n resolveErrorMessageAssertions,\n type OptionsAssertIs\n} from \"../_private/assertIs\";\n\n/** --------------------------------------------------------------------------------\n * * ***Type guard assertion: `assertIsBigInt`.***\n * ---------------------------------------------------------------------------------\n * **This function is an **assertion function**.**\n *\n * - **Behavior:**\n * - Validates that the given `value` is a **bigint**.\n * - After it returns successfully, TypeScript narrows the type of `value` to `bigint`.\n * - If `value` is a `bigint` ➔ execution continues normally.\n * - If `value` is not a `bigint` ➔ throws a built-in error with either:\n * - A custom error message (`options.message`), or\n * - A default message including the actual type.\n * - **Note:**\n * - A `bigint` refers strictly to the JavaScript `bigint` primitive type (e.g., `123n`, `0n`, `-999999999999999999999n`).\n * - This excludes `BigInt` objects created with `Object(BigInt(123))`.\n * - **Error type selection (`options.errorType`):**\n * - You can override the type of error thrown when validation fails.\n * - Must be one of the standard JavaScript built-in errors:\n * - [`TypeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError) |\n * [`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) |\n * [`EvalError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/EvalError) |\n * [`RangeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RangeError) |\n * [`ReferenceError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ReferenceError) |\n * [`SyntaxError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SyntaxError) |\n * [`URIError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/URIError).\n * - **Default:** `\"TypeError\"` if not provided or invalid.\n *\n * @param {*} value - ***The value to validate.***\n * @param {OptionsAssertIs} [options]\n * ***Optional configuration:***\n * - `message`: A custom error message (`string` or `function`).\n * - `errorType`: Built-in JavaScript error type to throw on failure (default `\"TypeError\"`).\n * - `formatCase`: Controls how detected type names are formatted case in error messages.\n * - `useAcronyms`: Control uppercase preservation of recognized acronyms during formatting.\n *\n * @throws [`TypeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError) | [`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) | [`EvalError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/EvalError) | [`RangeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RangeError) | [`ReferenceError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ReferenceError) | [`SyntaxError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SyntaxError) | [`URIError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/URIError) if the value is not a bigint.\n * @returns {boolean} Narrows `value` to `bigint` if no error is thrown.\n *\n * @example\n * ```ts\n * // ✅ Simple usage\n * assertIsBigInt(123n);\n * // No error, value is bigint\n *\n * // ❌ Throws TypeError (default behavior)\n * assertIsBigInt(42);\n * // ➔ TypeError: \"Parameter input (`value`) must be of type `bigint`, but received: `number`.\"\n *\n * // ❌ Throws a TypeError with a custom string static message\n * assertIsBigInt(\"123\", { message: \"Must be a bigint!\" });\n * // ➔ TypeError: \"Must be a bigint!\"\n *\n * // ❌ Throws custom error type (e.g., RangeError)\n * assertIsBigInt(async function () {}, { errorType: \"RangeError\" });\n * // ➔ RangeError: \"Parameter input (`value`) must be of type `bigint`, but received: `async-function`.\"\n *\n * // ❌ Throws a TypeError with a custom message function and formatCase\n * assertIsBigInt(/regex/, {\n * message: ({ currentType, validType }) => {\n * return `Expected ${validType} but got (${currentType}).`\n * },\n * formatCase: \"toPascalCaseSpace\"\n * });\n * // ➔ TypeError: \"Expected bigint but got (Reg Exp).\"\n *\n * // ❌ Throws a TypeError with a custom useAcronyms option\n * // Case 1:\n * assertIsBigInt(new URL(\"https://example.com\"),{\n * message: ({ currentType, validType }) => {\n * return `Expected ${validType} but got (${currentType}).`\n * },\n * });\n * // ➔ TypeError: \"Expected bigint but got (url).\"\n * assertIsBigInt(new URL(\"https://example.com\"), {\n * useAcronyms: true,\n * message: ({ currentType, validType }) => {\n * return `Expected ${validType} but got (${currentType}).`\n * },\n * });\n * // ➔ TypeError: \"Expected bigint but got (URL).\"\n *\n * // Case 2:\n * assertIsBigInt(new URLSearchParams, {\n * formatCase: \"toPascalCase\",\n * message: ({ currentType, validType }) => {\n * return `Expected ${validType} but got (${currentType}).`\n * },\n * });\n * // ➔ TypeError: \"Expected bigint but got (UrlSearchParams).\"\n * assertIsBigInt(new URLSearchParams, {\n * useAcronyms: true,\n * formatCase: \"toPascalCase\",\n * message: ({ currentType, validType }) => {\n * return `Expected ${validType} but got (${currentType}).`\n * },\n * });\n * // ➔ TypeError: \"Expected bigint but got (URLSearchParams).\"\n * ```\n * -------------------------------------------------------\n * ✅ ***Real-world usage example***:\n * ```ts\n * const mixedValue: string | bigint | undefined = getUserInput();\n *\n * // Runtime assertion: throws if `mixedValue` is not a `bigint`\n * assertIsBigInt(mixedValue, {\n * errorType: \"RangeError\",\n * message: \"Must be bigint!\"\n * });\n *\n * // ✅ If no error thrown, TypeScript narrows `mixedValue` to `bigint` here\n * const result: bigint = mixedValue; // ➔ Safe type assignment\n * console.log(result + 100n); // ➔ Safe to operation\n * ```\n */\nexport const assertIsBigInt: (\n value: unknown,\n options?: OptionsAssertIs\n) => asserts value is bigint = (\n value: unknown,\n options?: OptionsAssertIs\n): asserts value is bigint => {\n if (isBigInt(value)) return;\n\n resolveErrorMessageAssertions({\n value,\n options,\n requiredValidType: \"bigint\"\n });\n};\n","import { isNumber, type IsNumberOptions } from \"@/predicates/is/isNumber\";\n\nimport {\n resolveErrorMessageAssertions,\n type OptionsAssertIs\n} from \"../_private/assertIs\";\n\ntype OptionsAssertIsNumber = OptionsAssertIs & IsNumberOptions;\n\n/** --------------------------------------------------------------------------------\n * * ***Type guard assertion: `assertIsNumber`.***\n * ---------------------------------------------------------------------------------\n * **This function is an **assertion function**.**\n *\n * - **Behavior:**\n * - Validates that the given `value` is a **number**.\n * - After it returns successfully, TypeScript narrows the type of `value` to `number`.\n * - If `value` is a `number` ➔ execution continues normally.\n * - If `value` is not a `number` ➔ throws a built-in error with either:\n * - A custom error message (`options.message`), or\n * - A default message including the actual type.\n * - **Note:**\n * - A `number` refers strictly to the JavaScript `number` primitive type (e.g., `42`, `3.14`, `-1`, `0`).\n * - This excludes `Number` objects created with `new Number(123)`.\n * - By default, `NaN` is **not considered** valid, you can allow it with `{ includeNaN: true }`.\n * - **Error type selection (`options.errorType`):**\n * - You can override the type of error thrown when validation fails.\n * - Must be one of the standard JavaScript built-in errors:\n * - [`TypeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError) |\n * [`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) |\n * [`EvalError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/EvalError) |\n * [`RangeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RangeError) |\n * [`ReferenceError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ReferenceError) |\n * [`SyntaxError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SyntaxError) |\n * [`URIError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/URIError).\n * - **Default:** `\"TypeError\"` if not provided or invalid.\n *\n * @param {*} value - ***The value to validate.***\n * @param {OptionsAssertIsNumber} [options]\n * ***Optional configuration:***\n * - `message`: A custom error message (`string` or `function`).\n * - `errorType`: Built-in JavaScript error type to throw on failure (default `\"TypeError\"`).\n * - `formatCase`: Controls how detected type names are formatted case in error messages.\n * - `useAcronyms`: Control uppercase preservation of recognized acronyms during formatting.\n * - `includeNaN`: Whether to treat `NaN` as valid.\n *\n * @throws [`TypeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError) | [`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) | [`EvalError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/EvalError) | [`RangeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RangeError) | [`ReferenceError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ReferenceError) | [`SyntaxError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SyntaxError) | [`URIError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/URIError) if the value is not a number (or is `NaN` when `includeNaN` is `false`).\n * @returns {boolean} Narrows `value` to `number` if no error is thrown.\n *\n * @example\n * ```ts\n * // ✅ Simple usage\n * assertIsNumber(123);\n * assertIsNumber(NaN, { includeNaN: true });\n * // No error, value is number\n *\n * // ❌ Throws TypeError (default behavior)\n * // Case 1: Invalid input type — received a string instead of a number\n * assertIsNumber(\"42\");\n * // ➔ TypeError: \"Parameter input (`value`) must be of type `number`, but received: `string`.\"\n *\n * // Case 2: Default option includeNaN is false\n * assertIsNumber(NaN);\n * // ➔ TypeError: \"Parameter input (`value`) must be of type `number`, but received: `NaN`.\"\n *\n * // Case 3: The new Number() is a Number object (constructor), not a primitive number\n * assertIsNumber(new Number(\"123\"));\n * // ➔ TypeError: \"Parameter input (`value`) must be of type `number`, but received: `number-constructor`.\"\n *\n * // ❌ Throws custom error type (e.g., RangeError)\n * assertIsNumber(async function () {}, { errorType: \"RangeError\" });\n * // ➔ RangeError: \"Parameter input (`value`) must be of type `number`, but received: `async-function`.\"\n *\n * // ❌ Throws a TypeError with a custom string static message\n * assertIsNumber(\"123\", { message: \"Must be a number!\" });\n * // ➔ TypeError: \"Must be a number!\"\n *\n * // ❌ Throws a TypeError with a custom message function and formatCase\n * assertIsNumber(/regex/, {\n * message: ({ currentType, validType }) => {\n * return `Expected ${validType} but got (${currentType}).`\n * },\n * formatCase: \"toPascalCaseSpace\"\n * });\n * // ➔ TypeError: \"Expected number but got (Reg Exp).\"\n *\n * // ❌ Throws a TypeError with a custom useAcronyms option\n * // Case 1:\n * assertIsNumber(new URL(\"https://example.com\"),{\n * message: ({ currentType, validType }) => {\n * return `Expected ${validType} but got (${currentType}).`\n * },\n * });\n * // ➔ TypeError: \"Expected number but got (url).\"\n * assertIsNumber(new URL(\"https://example.com\"), {\n * useAcronyms: true,\n * message: ({ currentType, validType }) => {\n * return `Expected ${validType} but got (${currentType}).`\n * },\n * });\n * // ➔ TypeError: \"Expected number but got (URL).\"\n *\n * // Case 2:\n * assertIsNumber(new URLSearchParams, {\n * formatCase: \"toPascalCase\",\n * message: ({ currentType, validType }) => {\n * return `Expected ${validType} but got (${currentType}).`\n * },\n * });\n * // ➔ TypeError: \"Expected number but got (UrlSearchParams).\"\n * assertIsNumber(new URLSearchParams, {\n * useAcronyms: true,\n * formatCase: \"toPascalCase\",\n * message: ({ currentType, validType }) => {\n * return `Expected ${validType} but got (${currentType}).`\n * },\n * });\n * // ➔ TypeError: \"Expected number but got (URLSearchParams).\"\n * ```\n * -------------------------------------------------------\n * ✅ ***Real-world usage example***:\n * ```ts\n * const mixedValue: string | number | undefined = getUserInput();\n *\n * // Runtime assertion: throws if `mixedValue` is not a `number`\n * assertIsNumber(mixedValue, {\n * errorType: \"RangeError\",\n * message: \"Must be number!\"\n * });\n *\n * // ✅ If no error thrown, TypeScript narrows `mixedValue` to `number` here\n * const result: number = mixedValue; // ➔ Safe type assignment\n * console.log(result + 100); // ➔ Safe to operation\n * ```\n */\nexport const assertIsNumber: (\n value: unknown,\n options?: OptionsAssertIsNumber\n) => asserts value is number = (\n value: unknown,\n options?: OptionsAssertIsNumber\n): asserts value is number => {\n const includeNaN = options?.includeNaN ?? undefined;\n\n if (isNumber(value, { includeNaN })) return;\n\n resolveErrorMessageAssertions({\n value,\n options,\n requiredValidType: \"number\"\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyHA,MAAa,kBAIX,OACA,YAC4B;CAC5B,IAAI,SAAS,KAAK,GAAG;CAErB,8BAA8B;EAC5B;EACA;EACA,mBAAmB;CACrB,CAAC;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACAA,MAAa,kBAIX,OACA,YAC4B;CAG5B,IAAI,SAAS,OAAO,EAAE,YAFH,SAAS,cAAc,OAET,CAAC,GAAG;CAErC,8BAA8B;EAC5B;EACA;EACA,mBAAmB;CACrB,CAAC;AACH"}
|
|
@@ -2,18 +2,18 @@
|
|
|
2
2
|
* ========================================================================
|
|
3
3
|
* @rzl-zone/utils-js
|
|
4
4
|
* ------------------------------------------------------------------------
|
|
5
|
-
* Version: `3.
|
|
5
|
+
* Version: `3.14.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_toStringArrayUnRecursive = require('../toStringArrayUnRecursive-
|
|
13
|
-
const require_conversions = require('../conversions-
|
|
14
|
-
const require_safeStableStringify = require('../safeStableStringify-
|
|
15
|
-
const require_parsing = require('../parsing-
|
|
16
|
-
const require_safeJsonParse = require('../safeJsonParse-
|
|
12
|
+
const require_toStringArrayUnRecursive = require('../toStringArrayUnRecursive-_lJEmBlf.cjs');
|
|
13
|
+
const require_conversions = require('../conversions-UdMB90xR.cjs');
|
|
14
|
+
const require_safeStableStringify = require('../safeStableStringify-MuBiT-4B.cjs');
|
|
15
|
+
const require_parsing = require('../parsing-DB_S0WFz.cjs');
|
|
16
|
+
const require_safeJsonParse = require('../safeJsonParse-B5F8XtrZ.cjs');
|
|
17
17
|
exports.cleanParsedData = require_safeJsonParse.cleanParsedData;
|
|
18
18
|
exports.convertType = require_conversions.convertType;
|
|
19
19
|
exports.dedupeArray = require_conversions.dedupeArray;
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
* ========================================================================
|
|
3
3
|
* @rzl-zone/utils-js
|
|
4
4
|
* ------------------------------------------------------------------------
|
|
5
|
-
* Version: `3.
|
|
5
|
+
* Version: `3.14.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 { _ as dedupeArray, a as removeObjectPaths, c as parseCustomDate, d as parseCurrencyString, f as toBooleanLoose, g as filterNilArray, h as toBooleanContent, i as safeStableStringify, l as cleanParsedData, m as toBooleanContentDeep, n as toStringDeep, o as extractDigits, p as toBooleanExplicit, r as toNumberDeep, s as safeJsonParse, t as toStringDeepForce, u as convertType, v as toStringArrayUnRecursive, y as toNumberArrayUnRecursive } from "../index-
|
|
11
|
+
import { _ as dedupeArray, a as removeObjectPaths, c as parseCustomDate, d as parseCurrencyString, f as toBooleanLoose, g as filterNilArray, h as toBooleanContent, i as safeStableStringify, l as cleanParsedData, m as toBooleanContentDeep, n as toStringDeep, o as extractDigits, p as toBooleanExplicit, r as toNumberDeep, s as safeJsonParse, t as toStringDeepForce, u as convertType, v as toStringArrayUnRecursive, y as toNumberArrayUnRecursive } from "../index-zAqCZxGr.cjs";
|
|
12
12
|
export { cleanParsedData, convertType, dedupeArray, extractDigits, filterNilArray, parseCurrencyString, parseCustomDate, removeObjectPaths, safeJsonParse, safeStableStringify, toBooleanContent, toBooleanContentDeep, toBooleanExplicit, toBooleanLoose, toNumberArrayUnRecursive, toNumberDeep, toStringArrayUnRecursive, toStringDeep, toStringDeepForce };
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
* ========================================================================
|
|
3
3
|
* @rzl-zone/utils-js
|
|
4
4
|
* ------------------------------------------------------------------------
|
|
5
|
-
* Version: `3.
|
|
5
|
+
* Version: `3.14.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 { _ as dedupeArray, a as removeObjectPaths, c as parseCustomDate, d as parseCurrencyString, f as toBooleanLoose, g as filterNilArray, h as toBooleanContent, i as safeStableStringify, l as cleanParsedData, m as toBooleanContentDeep, n as toStringDeep, o as extractDigits, p as toBooleanExplicit, r as toNumberDeep, s as safeJsonParse, t as toStringDeepForce, u as convertType, v as toStringArrayUnRecursive, y as toNumberArrayUnRecursive } from "../index-
|
|
11
|
+
import { _ as dedupeArray, a as removeObjectPaths, c as parseCustomDate, d as parseCurrencyString, f as toBooleanLoose, g as filterNilArray, h as toBooleanContent, i as safeStableStringify, l as cleanParsedData, m as toBooleanContentDeep, n as toStringDeep, o as extractDigits, p as toBooleanExplicit, r as toNumberDeep, s as safeJsonParse, t as toStringDeepForce, u as convertType, v as toStringArrayUnRecursive, y as toNumberArrayUnRecursive } from "../index-BcoUy2oV.js";
|
|
12
12
|
export { cleanParsedData, convertType, dedupeArray, extractDigits, filterNilArray, parseCurrencyString, parseCustomDate, removeObjectPaths, safeJsonParse, safeStableStringify, toBooleanContent, toBooleanContentDeep, toBooleanExplicit, toBooleanLoose, toNumberArrayUnRecursive, toNumberDeep, toStringArrayUnRecursive, toStringDeep, toStringDeepForce };
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
* ========================================================================
|
|
3
3
|
* @rzl-zone/utils-js
|
|
4
4
|
* ------------------------------------------------------------------------
|
|
5
|
-
* Version: `3.
|
|
5
|
+
* Version: `3.14.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 { n as filterNilArray, t as toStringArrayUnRecursive } from "../toStringArrayUnRecursive-
|
|
11
|
-
import { a as toBooleanLoose, c as toBooleanContent, d as toNumberArrayUnRecursive, i as convertType, l as dedupeArray, n as toNumberDeep, o as toBooleanExplicit, r as removeObjectPaths, s as toBooleanContentDeep, t as toStringDeep, u as toStringDeepForce } from "../conversions-
|
|
12
|
-
import { t as safeStableStringify } from "../safeStableStringify-
|
|
13
|
-
import { t as parseCurrencyString } from "../parsing-
|
|
14
|
-
import { i as parseCustomDate, n as extractDigits, r as cleanParsedData, t as safeJsonParse } from "../safeJsonParse-
|
|
10
|
+
import { n as filterNilArray, t as toStringArrayUnRecursive } from "../toStringArrayUnRecursive-U-nkEIDs.js";
|
|
11
|
+
import { a as toBooleanLoose, c as toBooleanContent, d as toNumberArrayUnRecursive, i as convertType, l as dedupeArray, n as toNumberDeep, o as toBooleanExplicit, r as removeObjectPaths, s as toBooleanContentDeep, t as toStringDeep, u as toStringDeepForce } from "../conversions-BkxqYXxy.js";
|
|
12
|
+
import { t as safeStableStringify } from "../safeStableStringify-CDSYnLUz.js";
|
|
13
|
+
import { t as parseCurrencyString } from "../parsing-DhIQhWpX.js";
|
|
14
|
+
import { i as parseCustomDate, n as extractDigits, r as cleanParsedData, t as safeJsonParse } from "../safeJsonParse-DYSkUnhM.js";
|
|
15
15
|
export { cleanParsedData, convertType, dedupeArray, extractDigits, filterNilArray, parseCurrencyString, parseCustomDate, removeObjectPaths, safeJsonParse, safeStableStringify, toBooleanContent, toBooleanContentDeep, toBooleanExplicit, toBooleanLoose, toNumberArrayUnRecursive, toNumberDeep, toStringArrayUnRecursive, toStringDeep, toStringDeepForce };
|
|
@@ -2,25 +2,26 @@
|
|
|
2
2
|
* ========================================================================
|
|
3
3
|
* @rzl-zone/utils-js
|
|
4
4
|
* ------------------------------------------------------------------------
|
|
5
|
-
* Version: `3.
|
|
5
|
+
* Version: `3.14.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 isBigInt } from "./isBigInt-
|
|
12
|
-
import { t as
|
|
13
|
-
import { t as
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import { n as
|
|
17
|
-
import {
|
|
18
|
-
import { t as
|
|
19
|
-
import { n as isNonEmptyValue, t as isTypedArray } from "./isTypedArray-
|
|
10
|
+
import { A as isFunction, C as isNumberObject, D as isObject, E as isPlainObject, O as isArray, S as isNaN, T as isString, _ as isBooleanObject, b as isError, g as isObjectOrArray, h as isInfinityNumber, i as getPreciseType, j as isBoolean, k as isNil, n as assertIsBoolean, p as isSet, t as createMessage, v as isStringObject, w as isNonEmptyString, x as isNull, y as isBuffer } from "./logger-Wxl_Krg6.js";
|
|
11
|
+
import { t as isBigInt } from "./isBigInt-DdFRCpeE.js";
|
|
12
|
+
import { t as isNumber } from "./isNumber-C1mOuBuA.js";
|
|
13
|
+
import { t as assertIsArray } from "./assertIsArray-DmlqnTiq.js";
|
|
14
|
+
import { t as assertIsPlainObject } from "./assertIsPlainObject-CIzDchLs.js";
|
|
15
|
+
import { t as assertIsString } from "./assertIsString-sgY3ml5f.js";
|
|
16
|
+
import { n as isEmptyObject, r as isEmptyArray } from "./isEmptyValue-h97JT4pD.js";
|
|
17
|
+
import { n as filterNilArray } from "./toStringArrayUnRecursive-U-nkEIDs.js";
|
|
18
|
+
import { a as isMap, i as isDate, n as isSymbol, r as isUndefined, t as safeStableStringify } from "./safeStableStringify-CDSYnLUz.js";
|
|
19
|
+
import { n as isNonEmptyValue, o as isRegExp, r as isEqual, t as isTypedArray } from "./isTypedArray-BY8CIj3k.js";
|
|
20
|
+
import { t as isEmptyString } from "./isEmptyString-B6ubItgT.js";
|
|
20
21
|
function toNumberArrayUnRecursive(array, options = {}) {
|
|
21
|
-
|
|
22
|
-
const riv =
|
|
23
|
-
assertIsBoolean(riv, { message: ({ currentType, validType }) => `Parameter \`removeInvalidValueNumber\` property of the \`options\` (second parameter) must be of type \`${validType}\`, but received: \`${currentType}\`.` });
|
|
22
|
+
if (!isPlainObject(options)) options = {};
|
|
23
|
+
const riv = options.removeInvalidValueNumber ?? true;
|
|
24
|
+
assertIsBoolean(riv, { message: ({ currentType, validType }) => createMessage("toNumberArrayUnRecursive", `Parameter \`removeInvalidValueNumber\` property of the \`options\` (second parameter) must be of type \`${validType}\`, but received: \`${currentType}\`.`) });
|
|
24
25
|
if (isArray(array)) {
|
|
25
26
|
const result = Array.from(array, (x) => {
|
|
26
27
|
if (isBigInt(x)) return Number(x);
|
|
@@ -31,7 +32,7 @@ function toNumberArrayUnRecursive(array, options = {}) {
|
|
|
31
32
|
}
|
|
32
33
|
}
|
|
33
34
|
function toStringDeepForce(value, forceToString) {
|
|
34
|
-
if (!(forceToString === false || forceToString === "stringOrNumber" || forceToString === "primitives" || forceToString === "all")) throw new TypeError(`Second parameter \`forceToString\` must be of type \`false\` or \`string\` with value one of "stringOrNumber" | "primitives" | "all", but received: \`${getPreciseType(forceToString)}\`, with value: \`${safeStableStringify(forceToString, { keepUndefined: true })}\`.`);
|
|
35
|
+
if (!(forceToString === false || forceToString === "stringOrNumber" || forceToString === "primitives" || forceToString === "all")) throw new TypeError(createMessage("toStringDeepForce", `Second parameter \`forceToString\` must be of type \`false\` or \`string\` with value one of "stringOrNumber" | "primitives" | "all", but received: \`${getPreciseType(forceToString)}\`, with value: \`${safeStableStringify(forceToString, { keepUndefined: true })}\`.`));
|
|
35
36
|
if (isNaN(value)) return forceToString === "primitives" || forceToString === "all" ? "NaN" : NaN;
|
|
36
37
|
if (isString(value) || isNumber(value)) return forceToString === "stringOrNumber" || forceToString === "primitives" || forceToString === "all" ? String(value) : value;
|
|
37
38
|
if (isBoolean(value) || isBigInt(value) || isNil(value)) return forceToString === "primitives" || forceToString === "all" ? String(value) : value;
|
|
@@ -52,12 +53,12 @@ function toStringDeepForce(value, forceToString) {
|
|
|
52
53
|
return value;
|
|
53
54
|
}
|
|
54
55
|
const dedupeArray = (inputArray, options = {}) => {
|
|
55
|
-
assertIsArray(inputArray, { message: ({ currentType, validType }) => `First parameter (\`inputArray\`) must be of type \`${validType}\` (array literal or instance), but received: \`${currentType}\`.` });
|
|
56
|
-
assertIsPlainObject(options, { message: ({ currentType, validType }) => `Second parameter (\`options\`) must be of type \`${validType}\`, but received: \`${currentType}\`.` });
|
|
57
|
-
const flatten =
|
|
58
|
-
const forceToString =
|
|
59
|
-
if (!(forceToString === false || forceToString === "stringOrNumber" || forceToString === "primitives" || forceToString === "all")) throw new TypeError(`Parameter \`forceToString\` property of the \`options\` (second parameter) must be of type \`false\` or \`string\` with value one of "stringOrNumber" | "primitives" | "all", but received: \`${getPreciseType(forceToString)}\`, with value: \`${safeStableStringify(forceToString, { keepUndefined: true })}\`.`);
|
|
60
|
-
assertIsBoolean(flatten, { message: ({ currentType, validType }) => `Parameter \`flatten\` property of the \`options\` (second parameter) must be of type \`${validType}\`, but received: \`${currentType}\`.` });
|
|
56
|
+
assertIsArray(inputArray, { message: ({ currentType, validType }) => errorMsg$1(`First parameter (\`inputArray\`) must be of type \`${validType}\` (array literal or instance), but received: \`${currentType}\`.`) });
|
|
57
|
+
assertIsPlainObject(options, { message: ({ currentType, validType }) => errorMsg$1(`Second parameter (\`options\`) must be of type \`${validType}\`, but received: \`${currentType}\`.`) });
|
|
58
|
+
const flatten = options.flatten ?? false;
|
|
59
|
+
const forceToString = options.forceToString ?? false;
|
|
60
|
+
if (!(forceToString === false || forceToString === "stringOrNumber" || forceToString === "primitives" || forceToString === "all")) throw new TypeError(errorMsg$1(`Parameter \`forceToString\` property of the \`options\` (second parameter) must be of type \`false\` or \`string\` with value one of "stringOrNumber" | "primitives" | "all", but received: \`${getPreciseType(forceToString)}\`, with value: \`${safeStableStringify(forceToString, { keepUndefined: true })}\`.`));
|
|
61
|
+
assertIsBoolean(flatten, { message: ({ currentType, validType }) => errorMsg$1(`Parameter \`flatten\` property of the \`options\` (second parameter) must be of type \`${validType}\`, but received: \`${currentType}\`.`) });
|
|
61
62
|
const process = (arr) => {
|
|
62
63
|
const seen = [];
|
|
63
64
|
return arr.reduce((acc, item) => {
|
|
@@ -77,6 +78,7 @@ const dedupeArray = (inputArray, options = {}) => {
|
|
|
77
78
|
};
|
|
78
79
|
return flatten ? process(deepFlatten(inputArray)) : process(inputArray);
|
|
79
80
|
};
|
|
81
|
+
const errorMsg$1 = (msg) => createMessage("dedupeArray", msg);
|
|
80
82
|
const toBooleanContent = (value) => {
|
|
81
83
|
if (isNil(value)) return false;
|
|
82
84
|
if (isString(value)) return isNonEmptyString(value);
|
|
@@ -97,10 +99,10 @@ const toBooleanContentDeep = (value) => {
|
|
|
97
99
|
const toBooleanExplicit = (value, options = {}) => {
|
|
98
100
|
if (isNil(value)) return false;
|
|
99
101
|
if (!isPlainObject(options)) options = {};
|
|
100
|
-
const ci =
|
|
101
|
-
const ts =
|
|
102
|
-
const incInd =
|
|
103
|
-
if (!isBoolean(ci) || !isBoolean(ts) || !isBoolean(incInd)) throw new TypeError(`Parameters \`caseInsensitive\`, \`trimString\` and \`includeIndeterminate\` property of the \`options\` (second parameter) expected to be a \`boolean\` type, but received: ['caseInsensitive': \`${getPreciseType(ci)}\`, 'trimString': \`${getPreciseType(ts)}\`, 'includeIndeterminate': \`${getPreciseType(incInd)}\`].`);
|
|
102
|
+
const ci = options.caseInsensitive ?? false;
|
|
103
|
+
const ts = options.trimString ?? true;
|
|
104
|
+
const incInd = options.includeIndeterminate ?? false;
|
|
105
|
+
if (!isBoolean(ci) || !isBoolean(ts) || !isBoolean(incInd)) throw new TypeError(createMessage("toBooleanExplicit", `Parameters \`caseInsensitive\`, \`trimString\` and \`includeIndeterminate\` property of the \`options\` (second parameter) expected to be a \`boolean\` type, but received: ['caseInsensitive': \`${getPreciseType(ci)}\`, 'trimString': \`${getPreciseType(ts)}\`, 'includeIndeterminate': \`${getPreciseType(incInd)}\`].`));
|
|
104
106
|
if (isString(value)) {
|
|
105
107
|
let normalized = value;
|
|
106
108
|
if (ts) normalized = normalized.trim();
|
|
@@ -170,25 +172,26 @@ const deleteExactPathOnce = (obj, path) => {
|
|
|
170
172
|
};
|
|
171
173
|
function removeObjectPaths(object, keysToDelete, deepClone = true) {
|
|
172
174
|
if (isEmptyObject(object, { checkSymbols: true })) return {};
|
|
173
|
-
assertIsArray(keysToDelete, { message: ({ currentType, validType }) => `Second parameter (\`keysToDelete\`) must be of type \`${validType}\` with value of { key: string, deep?: boolean } plain-object, but received: \`${currentType}\`, with value: \`${safeStableStringify(keysToDelete, { keepUndefined: true })}\`.` });
|
|
174
|
-
if (!keysToDelete.every((k) => isPlainObject(k) && "key" in k)) throw new TypeError(`Each element in Second Parameter (\`keysToDelete\`) must be of type \`plain-object\` with at least a "key" property (optionally "deep"), but received: \`${safeStableStringify(keysToDelete, { keepUndefined: true })}\`.`);
|
|
175
|
+
assertIsArray(keysToDelete, { message: ({ currentType, validType }) => errorMsg(`Second parameter (\`keysToDelete\`) must be of type \`${validType}\` with value of { key: string, deep?: boolean } plain-object, but received: \`${currentType}\`, with value: \`${safeStableStringify(keysToDelete, { keepUndefined: true })}\`.`) });
|
|
176
|
+
if (!keysToDelete.every((k) => isPlainObject(k) && "key" in k)) throw new TypeError(errorMsg(`Each element in Second Parameter (\`keysToDelete\`) must be of type \`plain-object\` with at least a "key" property (optionally "deep"), but received: \`${safeStableStringify(keysToDelete, { keepUndefined: true })}\`.`));
|
|
175
177
|
let result = deepClone ? deepCloneSafe(object) : object;
|
|
176
178
|
for (const { key, deep } of keysToDelete) {
|
|
177
|
-
assertIsString(key, { message: ({ currentType, validType }) => `Parameter \`key\` at Second Parameter (\`keysToDelete\`) must be of type \`${validType}\`, but received: \`${currentType}\`.` });
|
|
178
|
-
if (!isUndefined(deep) && !isBoolean(deep)) throw new TypeError(`Parameter \`deep\` at Second Parameter (\`keysToDelete\`) ➔ (key: "${key}", deep: ${deep}) must be of type \`boolean\` or \`undefined\`, but received: \`${getPreciseType(deep)}\`.`);
|
|
179
|
+
assertIsString(key, { message: ({ currentType, validType }) => errorMsg(`Parameter \`key\` at Second Parameter (\`keysToDelete\`) must be of type \`${validType}\`, but received: \`${currentType}\`.`) });
|
|
180
|
+
if (!isUndefined(deep) && !isBoolean(deep)) throw new TypeError(errorMsg(`Parameter \`deep\` at Second Parameter (\`keysToDelete\`) ➔ (key: "${key}", deep: ${deep}) must be of type \`boolean\` or \`undefined\`, but received: \`${getPreciseType(deep)}\`.`));
|
|
179
181
|
const path = key.split(".");
|
|
180
182
|
result = deep ? deleteNestedKey(result, path) : deleteExactPathOnce(result, path);
|
|
181
183
|
}
|
|
182
184
|
return result;
|
|
183
185
|
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
const
|
|
186
|
+
const errorMsg = (msg) => createMessage("removeObjectPaths", msg);
|
|
187
|
+
function toNumberDeep(input, options) {
|
|
188
|
+
if (!isPlainObject(options)) options = {};
|
|
189
|
+
const removeEmptyObjects = options.removeEmptyObjects ?? false;
|
|
190
|
+
const removeEmptyArrays = options.removeEmptyArrays ?? false;
|
|
188
191
|
function _internal(input, options) {
|
|
189
192
|
if (isNil(input) || isRegExp(input)) return void 0;
|
|
190
193
|
const { removeEmptyArrays, removeEmptyObjects, isRoot } = options;
|
|
191
|
-
if (!isBoolean(removeEmptyObjects) || !isBoolean(removeEmptyArrays)) throw new TypeError(`Parameters \`removeEmptyObjects\` and \`removeEmptyArrays\` property of the \`options\` (second parameter) must be of type \`boolean\`, but received: ['removeEmptyObjects': \`${getPreciseType(removeEmptyObjects)}\`, 'removeEmptyArrays': \`${getPreciseType(removeEmptyArrays)}\`].`);
|
|
194
|
+
if (!isBoolean(removeEmptyObjects) || !isBoolean(removeEmptyArrays)) throw new TypeError(createMessage("toNumberDeep", `Parameters \`removeEmptyObjects\` and \`removeEmptyArrays\` property of the \`options\` (second parameter) must be of type \`boolean\`, but received: ['removeEmptyObjects': \`${getPreciseType(removeEmptyObjects)}\`, 'removeEmptyArrays': \`${getPreciseType(removeEmptyArrays)}\`].`));
|
|
192
195
|
if (isNumber(input) || isBoolean(input) || isNonEmptyString(input)) {
|
|
193
196
|
const num = Number(input);
|
|
194
197
|
return isInfinityNumber(num) || isNaN(num) ? void 0 : num;
|
|
@@ -284,14 +287,14 @@ function toNumberDeep(input, options = {}) {
|
|
|
284
287
|
isRoot: true
|
|
285
288
|
});
|
|
286
289
|
}
|
|
287
|
-
function toStringDeep(input, options
|
|
288
|
-
|
|
289
|
-
const removeEmptyObjects =
|
|
290
|
-
const removeEmptyArrays =
|
|
290
|
+
function toStringDeep(input, options) {
|
|
291
|
+
if (!isPlainObject(options)) options = {};
|
|
292
|
+
const removeEmptyObjects = options.removeEmptyObjects ?? false;
|
|
293
|
+
const removeEmptyArrays = options.removeEmptyArrays ?? false;
|
|
291
294
|
function _internal(input, options) {
|
|
292
295
|
if (isNil(input) || isInfinityNumber(input)) return void 0;
|
|
293
296
|
const { removeEmptyArrays, removeEmptyObjects, isRoot } = options;
|
|
294
|
-
if (!isBoolean(removeEmptyObjects) || !isBoolean(removeEmptyArrays)) throw new TypeError(`Parameters \`removeEmptyObjects\` and \`removeEmptyArrays\` property of the \`options\` (second parameter) must be of type \`boolean\`, but received: ['removeEmptyObjects': \`${getPreciseType(removeEmptyObjects)}\`, 'removeEmptyArrays': \`${getPreciseType(removeEmptyArrays)}\`].`);
|
|
297
|
+
if (!isBoolean(removeEmptyObjects) || !isBoolean(removeEmptyArrays)) throw new TypeError(createMessage("toStringDeep", `Parameters \`removeEmptyObjects\` and \`removeEmptyArrays\` property of the \`options\` (second parameter) must be of type \`boolean\`, but received: ['removeEmptyObjects': \`${getPreciseType(removeEmptyObjects)}\`, 'removeEmptyArrays': \`${getPreciseType(removeEmptyArrays)}\`].`));
|
|
295
298
|
if (isNumber(input) || isString(input) || isBoolean(input)) return String(input);
|
|
296
299
|
if (isNumberObject(input)) {
|
|
297
300
|
const valOf = input.valueOf();
|
|
@@ -377,4 +380,4 @@ function toStringDeep(input, options = {}) {
|
|
|
377
380
|
});
|
|
378
381
|
}
|
|
379
382
|
export { toBooleanLoose as a, toBooleanContent as c, toNumberArrayUnRecursive as d, convertType as i, dedupeArray as l, toNumberDeep as n, toBooleanExplicit as o, removeObjectPaths as r, toBooleanContentDeep as s, toStringDeep as t, toStringDeepForce as u };
|
|
380
|
-
//# sourceMappingURL=conversions-
|
|
383
|
+
//# sourceMappingURL=conversions-BkxqYXxy.js.map
|