@rzl-zone/utils-js 3.13.1 → 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-HgzPQIAM.js → assertIsArray-CG7L7vlt.js} +3 -3
- package/dist/assertIsArray-CG7L7vlt.js.map +1 -0
- package/dist/{assertIsArray-CeXL4xv5.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-CY_WkCLr.js → assertIsString-CHIwE12y.js} +4 -4
- package/dist/assertIsString-CHIwE12y.js.map +1 -0
- package/dist/{assertIsString-DUrVt82d.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-1s7xMBe_.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-C6cVZBbG.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-RNQBTK8A.d.cts → index-9JsU_wMu.d.ts} +1375 -937
- package/dist/{index-ORbo-7zA.d.cts → index-BP3sUrAx.d.ts} +242 -133
- package/dist/{index-BG8wdusZ.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-CRz9rSZL.d.ts → index-Dwduk7ez.d.cts} +1375 -937
- package/dist/{index-DPJ-e2JZ.d.ts → index-I5V6RbZM.d.cts} +1592 -790
- package/dist/{index-B5EBAgmC.d.cts → index-hOqBIL7F.d.ts} +1592 -790
- package/dist/{index-B1VQ6USF.d.ts → index-jyuOZMX7.d.ts} +229 -200
- package/dist/{index-ORbo-7zA.d.ts → index-lI0b7iUz.d.cts} +242 -133
- package/dist/{isBigInt-y7s3rsKc.js → isBigInt-Cez32M69.js} +2 -2
- package/dist/isBigInt-Cez32M69.js.map +1 -0
- package/dist/{isBigInt-BVj0M5pq.cjs → isBigInt-YgpNKTbA.cjs} +2 -2
- package/dist/isBigInt-YgpNKTbA.cjs.map +1 -0
- package/dist/{isEmptyString-BYMz_wt9.js → isEmptyString-C9QLWjx2.js} +4 -4
- package/dist/isEmptyString-C9QLWjx2.js.map +1 -0
- package/dist/{isEmptyString-C8PYNPgw.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-DeDaBDr2.cjs → isFinite-B_hHbDpa.cjs} +6 -6
- package/dist/isFinite-B_hHbDpa.cjs.map +1 -0
- package/dist/{isFinite-BEJFOv6B.js → isFinite-ZvNhyHlF.js} +5 -5
- package/dist/isFinite-ZvNhyHlF.js.map +1 -0
- package/dist/{isInteger-DEDbBGez.js → isInteger-aZgzTTZG.js} +4 -4
- package/dist/isInteger-aZgzTTZG.js.map +1 -0
- package/dist/{isInteger-CQLThJOR.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-q3o6cSwD.js → isServer-CQzrX5e0.js} +2 -2
- package/dist/isServer-CQzrX5e0.js.map +1 -0
- package/dist/{isServer-DmycqWsF.cjs → isServer-DhFaedeT.cjs} +2 -2
- package/dist/isServer-DhFaedeT.cjs.map +1 -0
- package/dist/{isEqual-DaPDxMyw.cjs → isTypedArray-DjADSu8q.cjs} +45 -13
- package/dist/isTypedArray-DjADSu8q.cjs.map +1 -0
- package/dist/{isEqual-DM4S_kWh.js → isTypedArray-DxsPKrLh.js} +29 -9
- package/dist/isTypedArray-DxsPKrLh.js.map +1 -0
- package/dist/{isValidDomain-B8Nukgw0.js → isValidDomain-CDtNOhMc.js} +13 -54
- package/dist/isValidDomain-CDtNOhMc.js.map +1 -0
- package/dist/{isValidDomain-ZbyeGOO9.cjs → isValidDomain-D_x7uNIu.cjs} +16 -69
- package/dist/isValidDomain-D_x7uNIu.cjs.map +1 -0
- package/dist/{assertIsBoolean-CWUs-I5l.js → logger-CLWnKRKE.js} +657 -587
- package/dist/logger-CLWnKRKE.js.map +1 -0
- package/dist/{assertIsBoolean-D41HrTB_.cjs → logger-CUacYy3D.cjs} +658 -612
- package/dist/logger-CUacYy3D.cjs.map +1 -0
- package/dist/{noop-BY43WaoU.cjs → noop-CjEbNsJL.cjs} +2 -2
- package/dist/noop-CjEbNsJL.cjs.map +1 -0
- package/dist/{noop-CjY8xVHv.js → noop-qxrcogt5.js} +2 -2
- package/dist/noop-qxrcogt5.js.map +1 -0
- package/dist/{normalizeSpaces-BhZp0U_6.cjs → normalizeSpaces-D0_Z4qnO.cjs} +6 -9
- package/dist/normalizeSpaces-D0_Z4qnO.cjs.map +1 -0
- package/dist/{normalizeSpaces-BoUDtq5P.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-B8KYXIjE.js → parsers-BBAE_xVM.js} +9 -8
- package/dist/parsers-BBAE_xVM.js.map +1 -0
- package/dist/{parsers-B_FPX35n.cjs → parsers-i8WEeMJl.cjs} +10 -9
- package/dist/parsers-i8WEeMJl.cjs.map +1 -0
- package/dist/{parsing-Bfaw85Hd.js → parsing-D9tbKQ0v.js} +3 -3
- package/dist/parsing-D9tbKQ0v.js.map +1 -0
- package/dist/{parsing-BCZGco7n.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-KlyOvBSC.js → predicates-C0dova7l.js} +45 -40
- package/dist/predicates-C0dova7l.js.map +1 -0
- package/dist/{predicates-8y28VrbT.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-DnKi0qjS.cjs → punyCode-DHTLhGdD.cjs} +12 -12
- package/dist/punyCode-DHTLhGdD.cjs.map +1 -0
- package/dist/{punyCode-Dwto1RpA.js → punyCode-Deb1Mrkc.js} +12 -12
- package/dist/punyCode-Deb1Mrkc.js.map +1 -0
- package/dist/{removeSpaces--8NW-HSx.js → removeSpaces-BPnsdRN0.js} +4 -4
- package/dist/removeSpaces-BPnsdRN0.js.map +1 -0
- package/dist/{removeSpaces-CmrrkeXz.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-OnUwG2El.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-B2KTTS3r.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-DUuboq52.cjs → tailwind-BG7B0cDs.cjs} +59 -53
- package/dist/tailwind-BG7B0cDs.cjs.map +1 -0
- package/dist/{tailwind-CUdmv-oO.js → tailwind-tJNnFPsF.js} +38 -32
- package/dist/tailwind-tJNnFPsF.js.map +1 -0
- package/dist/{toStringArrayUnRecursive-OOHGazks.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-BXT4Krsq.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-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,22 +2,24 @@
|
|
|
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 {
|
|
12
|
-
import {
|
|
13
|
-
/**
|
|
11
|
+
import { M as PickStrict, N as Prettify } from "./index-DZHiYYR7.js";
|
|
12
|
+
import { a as IsNumberOptions, c as GetPreciseTypeOptions, i as ArrayFallback, t as IsPlainObjectResult } from "./isPlainObject-CJvRG4Je.js";
|
|
13
|
+
/** -----------------------------------------------------------------------------
|
|
14
14
|
* * ***Shape of the object passed to custom error message functions.***
|
|
15
|
-
*
|
|
15
|
+
* ------------------------------------------------------------------------------
|
|
16
16
|
* **This type describes the parameters received when `options.message`
|
|
17
17
|
* is defined as a function in {@link OptionsAssertIs | `OptionsAssertIs`}.**
|
|
18
|
+
*
|
|
18
19
|
* - **Parameter:**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
20
|
+
* - `currentType` ➔ the actual detected runtime type of the value.
|
|
21
|
+
* - `validType` ➔ the required/expected type name that the value must match.
|
|
22
|
+
*
|
|
21
23
|
* @example
|
|
22
24
|
* ```ts
|
|
23
25
|
* const options: OptionsAssertIs = {
|
|
@@ -30,16 +32,16 @@ import { PickStrict, Prettify } from "@rzl-zone/ts-types-plus";
|
|
|
30
32
|
type OptionsMessageFunctionAssertIs = {
|
|
31
33
|
/** ---------------------------------------------------------------------------
|
|
32
34
|
* * ***The actual runtime type of the value being checked.***
|
|
33
|
-
*
|
|
35
|
+
* ----------------------------------------------------------------------------
|
|
34
36
|
* - ***Example:***
|
|
35
|
-
*
|
|
37
|
+
* - `"number"`, `"big-int"`, `"plain-object"`, (depends-on `formatCase` options).
|
|
36
38
|
*/
|
|
37
39
|
currentType: string;
|
|
38
40
|
/** ---------------------------------------------------------------------------
|
|
39
41
|
* * ***The required/expected type that the value must conform to.***
|
|
40
|
-
*
|
|
42
|
+
* ----------------------------------------------------------------------------
|
|
41
43
|
* - ***Example:***
|
|
42
|
-
*
|
|
44
|
+
* - `"boolean"`, `"string"`, `"big-int"`, `"plain-object"`, (will force format to `kebab-case`).
|
|
43
45
|
*/
|
|
44
46
|
validType: string;
|
|
45
47
|
};
|
|
@@ -47,8 +49,8 @@ type OptionsMessageFunctionAssertIs = {
|
|
|
47
49
|
* * ***Custom error-message type for assertions option {@link OptionsAssertIs | `OptionsAssertIs`}.***
|
|
48
50
|
* -------------------------------------------------------
|
|
49
51
|
* - ***Accepts:***
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
+
* - A static string message.
|
|
53
|
+
* - A function receiving `{ currentType, validType }` and returning a string.
|
|
52
54
|
*/
|
|
53
55
|
type OptionsMessageAssertIs = (({
|
|
54
56
|
currentType,
|
|
@@ -56,24 +58,26 @@ type OptionsMessageAssertIs = (({
|
|
|
56
58
|
}: OptionsMessageFunctionAssertIs) => string) | string;
|
|
57
59
|
/** ---------------------------------------------------------------------------
|
|
58
60
|
* * ***Base options for `assertIs*` functions.***
|
|
59
|
-
*
|
|
61
|
+
* ----------------------------------------------------------------------------
|
|
60
62
|
*/
|
|
61
63
|
type OptionsAssertIs = Prettify<{
|
|
62
|
-
/**
|
|
64
|
+
/** -----------------------------------------------------------------------
|
|
63
65
|
* * ***Custom error message for assertion failures.***
|
|
64
|
-
*
|
|
66
|
+
* ------------------------------------------------------------------------
|
|
65
67
|
* **This option allows overriding the **default error message** when a value
|
|
66
68
|
* does not match the required type.**
|
|
69
|
+
*
|
|
67
70
|
* - If a **string** is provided:
|
|
68
|
-
*
|
|
69
|
-
*
|
|
71
|
+
* - Must be non-empty after trimming.
|
|
72
|
+
* - Will be used directly as the error message.
|
|
70
73
|
* - If a **function** is provided:
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
74
|
+
* - Receives an object containing:
|
|
75
|
+
* - `currentType` ➔ the detected runtime type of the value (depends-on `formatCase` options, e.g., `"number"`).
|
|
76
|
+
* - `validType` ➔ the expected type name (with format `kebab-case`, e.g., `"boolean"`, `"big-int"`, `"plain-object"`).
|
|
77
|
+
* - **Must** return a **string**:
|
|
78
|
+
* - **If** the **returned string is** `empty` or `whitespace`,
|
|
79
|
+
* the **default message** will be used instead.
|
|
80
|
+
*
|
|
77
81
|
* @example
|
|
78
82
|
* ```ts
|
|
79
83
|
* // Static message
|
|
@@ -88,18 +92,19 @@ type OptionsAssertIs = Prettify<{
|
|
|
88
92
|
* ```
|
|
89
93
|
*/
|
|
90
94
|
message?: OptionsMessageAssertIs;
|
|
91
|
-
/**
|
|
95
|
+
/** -----------------------------------------------------------------------
|
|
92
96
|
* * ***Custom error type for assertion failures.***
|
|
93
|
-
*
|
|
97
|
+
* ------------------------------------------------------------------------
|
|
94
98
|
* **This option allows overriding the default error type** that will be thrown
|
|
95
99
|
* when a value does not match the required type.
|
|
96
100
|
*
|
|
97
101
|
* - **Behavior:**
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
*
|
|
102
|
+
* - Must be one of the standard JavaScript built-in error types:
|
|
103
|
+
* `"Error" | "EvalError" | "RangeError" | "ReferenceError" | "SyntaxError" | "TypeError" | "URIError"`.
|
|
104
|
+
* - **Default:** `"TypeError"` if not provided or if an invalid value is passed.
|
|
105
|
+
* - The assertion function will **always throw a valid built-in error**, ensuring
|
|
106
|
+
* fallback to `TypeError` in case of an unknown or incorrect type.
|
|
107
|
+
*
|
|
103
108
|
* @example
|
|
104
109
|
* ```ts
|
|
105
110
|
* // Valid: Throw a RangeError instead of TypeError
|
|
@@ -114,40 +119,44 @@ type OptionsAssertIs = Prettify<{
|
|
|
114
119
|
*/
|
|
115
120
|
errorType?: ErrorType;
|
|
116
121
|
} & PickStrict<GetPreciseTypeOptions, "formatCase" | "useAcronyms">, {
|
|
117
|
-
recursive:
|
|
122
|
+
recursive: false;
|
|
118
123
|
}>;
|
|
119
124
|
type ErrorType = "Error" | "EvalError" | "RangeError" | "ReferenceError" | "SyntaxError" | "TypeError" | "URIError";
|
|
120
|
-
/**
|
|
125
|
+
/** ---------------------------------------------------------------------------------
|
|
121
126
|
* * ***Type guard assertion: `assertIsBoolean`.***
|
|
122
|
-
*
|
|
127
|
+
* ----------------------------------------------------------------------------------
|
|
123
128
|
* **This function is an **assertion function**.**
|
|
129
|
+
*
|
|
124
130
|
* - **Behavior:**
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
*
|
|
128
|
-
*
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
* -
|
|
132
|
-
*
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
*
|
|
140
|
-
*
|
|
141
|
-
*
|
|
131
|
+
* - Validates that the given `value` is a **boolean**.
|
|
132
|
+
* - After it returns successfully, TypeScript narrows the type of `value` to `boolean`.
|
|
133
|
+
* - If `value` is a `boolean` ➔ execution continues normally.
|
|
134
|
+
* - If `value` is not a `boolean` ➔ throws a built-in error with either:
|
|
135
|
+
* - A custom error message (`options.message`), or
|
|
136
|
+
* - A default message including the actual type.
|
|
137
|
+
* - **Error type selection (`options.errorType`):**
|
|
138
|
+
* - You can override the type of error thrown when validation fails.
|
|
139
|
+
* - Must be one of the standard JavaScript built-in errors:
|
|
140
|
+
* - [`TypeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError) |
|
|
141
|
+
* [`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) |
|
|
142
|
+
* [`EvalError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/EvalError) |
|
|
143
|
+
* [`RangeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RangeError) |
|
|
144
|
+
* [`ReferenceError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ReferenceError) |
|
|
145
|
+
* [`SyntaxError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SyntaxError) |
|
|
146
|
+
* [`URIError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/URIError).
|
|
147
|
+
* - **Default:** `"TypeError"` if not provided or invalid.
|
|
148
|
+
*
|
|
142
149
|
* @param {*} value - ***The value to validate.***
|
|
143
150
|
* @param {OptionsAssertIs} [options]
|
|
144
151
|
* ***Optional configuration:***
|
|
145
|
-
*
|
|
146
|
-
*
|
|
147
|
-
*
|
|
148
|
-
*
|
|
149
|
-
*
|
|
152
|
+
* - `message`: A custom error message (`string` or `function`).
|
|
153
|
+
* - `errorType`: A custom built-in JavaScript error type to throw.
|
|
154
|
+
* - `formatCase`: Controls how detected type names are formatted case in error messages.
|
|
155
|
+
* - `useAcronyms`: Control uppercase preservation of recognized acronyms during formatting.
|
|
156
|
+
*
|
|
150
157
|
* @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 boolean.
|
|
158
|
+
* @returns {boolean} Narrows `value` to `boolean` if no error is thrown.
|
|
159
|
+
*
|
|
151
160
|
* @example
|
|
152
161
|
* ```ts
|
|
153
162
|
* // ✅ Simple usage
|
|
@@ -229,40 +238,44 @@ type ErrorType = "Error" | "EvalError" | "RangeError" | "ReferenceError" | "Synt
|
|
|
229
238
|
* ```
|
|
230
239
|
*/
|
|
231
240
|
declare const assertIsBoolean: (value: unknown, options?: OptionsAssertIs) => asserts value is boolean;
|
|
232
|
-
/**
|
|
241
|
+
/** --------------------------------------------------------------------------------
|
|
233
242
|
* * ***Type guard assertion: `assertIsBigInt`.***
|
|
234
|
-
*
|
|
243
|
+
* ---------------------------------------------------------------------------------
|
|
235
244
|
* **This function is an **assertion function**.**
|
|
245
|
+
*
|
|
236
246
|
* - **Behavior:**
|
|
237
|
-
*
|
|
238
|
-
*
|
|
239
|
-
*
|
|
240
|
-
*
|
|
241
|
-
*
|
|
242
|
-
*
|
|
243
|
-
*
|
|
244
|
-
*
|
|
245
|
-
*
|
|
246
|
-
*
|
|
247
|
-
*
|
|
248
|
-
*
|
|
249
|
-
*
|
|
250
|
-
*
|
|
251
|
-
*
|
|
252
|
-
*
|
|
253
|
-
*
|
|
254
|
-
*
|
|
255
|
-
*
|
|
256
|
-
*
|
|
247
|
+
* - Validates that the given `value` is a **bigint**.
|
|
248
|
+
* - After it returns successfully, TypeScript narrows the type of `value` to `bigint`.
|
|
249
|
+
* - If `value` is a `bigint` ➔ execution continues normally.
|
|
250
|
+
* - If `value` is not a `bigint` ➔ throws a built-in error with either:
|
|
251
|
+
* - A custom error message (`options.message`), or
|
|
252
|
+
* - A default message including the actual type.
|
|
253
|
+
* - **Note:**
|
|
254
|
+
* - A `bigint` refers strictly to the JavaScript `bigint` primitive type (e.g., `123n`, `0n`, `-999999999999999999999n`).
|
|
255
|
+
* - This excludes `BigInt` objects created with `Object(BigInt(123))`.
|
|
256
|
+
* - **Error type selection (`options.errorType`):**
|
|
257
|
+
* - You can override the type of error thrown when validation fails.
|
|
258
|
+
* - Must be one of the standard JavaScript built-in errors:
|
|
259
|
+
* - [`TypeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError) |
|
|
260
|
+
* [`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) |
|
|
261
|
+
* [`EvalError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/EvalError) |
|
|
262
|
+
* [`RangeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RangeError) |
|
|
263
|
+
* [`ReferenceError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ReferenceError) |
|
|
264
|
+
* [`SyntaxError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SyntaxError) |
|
|
265
|
+
* [`URIError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/URIError).
|
|
266
|
+
* - **Default:** `"TypeError"` if not provided or invalid.
|
|
267
|
+
*
|
|
257
268
|
* @param {*} value - ***The value to validate.***
|
|
258
269
|
* @param {OptionsAssertIs} [options]
|
|
259
270
|
* ***Optional configuration:***
|
|
260
|
-
*
|
|
261
|
-
*
|
|
262
|
-
*
|
|
263
|
-
*
|
|
264
|
-
*
|
|
271
|
+
* - `message`: A custom error message (`string` or `function`).
|
|
272
|
+
* - `errorType`: Built-in JavaScript error type to throw on failure (default `"TypeError"`).
|
|
273
|
+
* - `formatCase`: Controls how detected type names are formatted case in error messages.
|
|
274
|
+
* - `useAcronyms`: Control uppercase preservation of recognized acronyms during formatting.
|
|
275
|
+
*
|
|
265
276
|
* @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.
|
|
277
|
+
* @returns {boolean} Narrows `value` to `bigint` if no error is thrown.
|
|
278
|
+
*
|
|
266
279
|
* @example
|
|
267
280
|
* ```ts
|
|
268
281
|
* // ✅ Simple usage
|
|
@@ -341,42 +354,46 @@ declare const assertIsBoolean: (value: unknown, options?: OptionsAssertIs) => as
|
|
|
341
354
|
*/
|
|
342
355
|
declare const assertIsBigInt: (value: unknown, options?: OptionsAssertIs) => asserts value is bigint;
|
|
343
356
|
type OptionsAssertIsNumber = OptionsAssertIs & IsNumberOptions;
|
|
344
|
-
/**
|
|
357
|
+
/** --------------------------------------------------------------------------------
|
|
345
358
|
* * ***Type guard assertion: `assertIsNumber`.***
|
|
346
|
-
*
|
|
359
|
+
* ---------------------------------------------------------------------------------
|
|
347
360
|
* **This function is an **assertion function**.**
|
|
361
|
+
*
|
|
348
362
|
* - **Behavior:**
|
|
349
|
-
*
|
|
350
|
-
*
|
|
351
|
-
*
|
|
352
|
-
*
|
|
353
|
-
*
|
|
354
|
-
*
|
|
355
|
-
* -
|
|
356
|
-
*
|
|
357
|
-
*
|
|
358
|
-
*
|
|
359
|
-
* -
|
|
360
|
-
*
|
|
361
|
-
*
|
|
362
|
-
*
|
|
363
|
-
*
|
|
364
|
-
*
|
|
365
|
-
*
|
|
366
|
-
*
|
|
367
|
-
*
|
|
368
|
-
*
|
|
369
|
-
*
|
|
363
|
+
* - Validates that the given `value` is a **number**.
|
|
364
|
+
* - After it returns successfully, TypeScript narrows the type of `value` to `number`.
|
|
365
|
+
* - If `value` is a `number` ➔ execution continues normally.
|
|
366
|
+
* - If `value` is not a `number` ➔ throws a built-in error with either:
|
|
367
|
+
* - A custom error message (`options.message`), or
|
|
368
|
+
* - A default message including the actual type.
|
|
369
|
+
* - **Note:**
|
|
370
|
+
* - A `number` refers strictly to the JavaScript `number` primitive type (e.g., `42`, `3.14`, `-1`, `0`).
|
|
371
|
+
* - This excludes `Number` objects created with `new Number(123)`.
|
|
372
|
+
* - By default, `NaN` is **not considered** valid, you can allow it with `{ includeNaN: true }`.
|
|
373
|
+
* - **Error type selection (`options.errorType`):**
|
|
374
|
+
* - You can override the type of error thrown when validation fails.
|
|
375
|
+
* - Must be one of the standard JavaScript built-in errors:
|
|
376
|
+
* - [`TypeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError) |
|
|
377
|
+
* [`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) |
|
|
378
|
+
* [`EvalError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/EvalError) |
|
|
379
|
+
* [`RangeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RangeError) |
|
|
380
|
+
* [`ReferenceError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ReferenceError) |
|
|
381
|
+
* [`SyntaxError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SyntaxError) |
|
|
382
|
+
* [`URIError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/URIError).
|
|
383
|
+
* - **Default:** `"TypeError"` if not provided or invalid.
|
|
384
|
+
*
|
|
370
385
|
* @param {*} value - ***The value to validate.***
|
|
371
386
|
* @param {OptionsAssertIsNumber} [options]
|
|
372
387
|
* ***Optional configuration:***
|
|
373
|
-
*
|
|
374
|
-
*
|
|
375
|
-
*
|
|
376
|
-
*
|
|
377
|
-
*
|
|
378
|
-
*
|
|
388
|
+
* - `message`: A custom error message (`string` or `function`).
|
|
389
|
+
* - `errorType`: Built-in JavaScript error type to throw on failure (default `"TypeError"`).
|
|
390
|
+
* - `formatCase`: Controls how detected type names are formatted case in error messages.
|
|
391
|
+
* - `useAcronyms`: Control uppercase preservation of recognized acronyms during formatting.
|
|
392
|
+
* - `includeNaN`: Whether to treat `NaN` as valid.
|
|
393
|
+
*
|
|
379
394
|
* @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`).
|
|
395
|
+
* @returns {boolean} Narrows `value` to `number` if no error is thrown.
|
|
396
|
+
*
|
|
380
397
|
* @example
|
|
381
398
|
* ```ts
|
|
382
399
|
* // ✅ Simple usage
|
|
@@ -464,38 +481,42 @@ type OptionsAssertIsNumber = OptionsAssertIs & IsNumberOptions;
|
|
|
464
481
|
* ```
|
|
465
482
|
*/
|
|
466
483
|
declare const assertIsNumber: (value: unknown, options?: OptionsAssertIsNumber) => asserts value is number;
|
|
467
|
-
/**
|
|
484
|
+
/** --------------------------------------------------------------------------------
|
|
468
485
|
* * ***Type guard assertion: `assertIsArray`.***
|
|
469
|
-
*
|
|
486
|
+
* ---------------------------------------------------------------------------------
|
|
470
487
|
* **This function is an **assertion function**.**
|
|
488
|
+
*
|
|
471
489
|
* - **Behavior:**
|
|
472
|
-
*
|
|
473
|
-
*
|
|
474
|
-
*
|
|
475
|
-
*
|
|
476
|
-
*
|
|
477
|
-
*
|
|
478
|
-
* -
|
|
479
|
-
*
|
|
480
|
-
*
|
|
481
|
-
*
|
|
482
|
-
*
|
|
483
|
-
*
|
|
484
|
-
*
|
|
485
|
-
*
|
|
486
|
-
*
|
|
487
|
-
*
|
|
488
|
-
*
|
|
490
|
+
* - Validates that the given `value` is an **array**.
|
|
491
|
+
* - After it returns successfully, TypeScript narrows the type of `value` to `array` **(generic support)**.
|
|
492
|
+
* - If `value` is an `array` ➔ execution continues normally.
|
|
493
|
+
* - If `value` is not an `array` ➔ throws a built-in error with either:
|
|
494
|
+
* - A custom error message (`options.message`), or
|
|
495
|
+
* - A default message including the actual type.
|
|
496
|
+
* - **Error type selection (`options.errorType`):**
|
|
497
|
+
* - You can override the type of error thrown when validation fails.
|
|
498
|
+
* - Must be one of the standard JavaScript built-in errors:
|
|
499
|
+
* - [`TypeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError) |
|
|
500
|
+
* [`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) |
|
|
501
|
+
* [`EvalError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/EvalError) |
|
|
502
|
+
* [`RangeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RangeError) |
|
|
503
|
+
* [`ReferenceError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ReferenceError) |
|
|
504
|
+
* [`SyntaxError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SyntaxError) |
|
|
505
|
+
* [`URIError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/URIError).
|
|
506
|
+
* - **Default:** `"TypeError"` if not provided or invalid.
|
|
507
|
+
*
|
|
489
508
|
* @template T - The input type being asserted.
|
|
490
509
|
* @param {*} value - ***The value to validate.***
|
|
491
510
|
* @param {OptionsAssertIs} [options]
|
|
492
511
|
* ***Optional configuration:***
|
|
493
|
-
*
|
|
494
|
-
*
|
|
495
|
-
*
|
|
496
|
-
*
|
|
497
|
-
*
|
|
512
|
+
* - `message`: A custom error message (`string` or `function`).
|
|
513
|
+
* - `errorType`: Built-in JavaScript error type to throw on failure (default `"TypeError"`).
|
|
514
|
+
* - `formatCase`: Controls how detected type names are formatted case in error messages.
|
|
515
|
+
* - `useAcronyms`: Control uppercase preservation of recognized acronyms during formatting.
|
|
516
|
+
*
|
|
498
517
|
* @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 an array.
|
|
518
|
+
* @returns {boolean} Narrows `value` to an `array` **(generic support)** if no error is thrown.
|
|
519
|
+
*
|
|
499
520
|
* @example
|
|
500
521
|
* ```ts
|
|
501
522
|
* // ✅ Simple usage
|
|
@@ -578,52 +599,56 @@ declare const assertIsNumber: (value: unknown, options?: OptionsAssertIsNumber)
|
|
|
578
599
|
declare function assertIsArray(value: [], options?: OptionsAssertIs): asserts value is [];
|
|
579
600
|
declare function assertIsArray<T>(value: T, options?: OptionsAssertIs): asserts value is ArrayFallback<T>;
|
|
580
601
|
declare function assertIsArray(value: unknown, options?: OptionsAssertIs): asserts value is unknown[];
|
|
581
|
-
/**
|
|
602
|
+
/** --------------------------------------------------------------------------------
|
|
582
603
|
* * ***Type guard assertion: `assertIsPlainObject`.***
|
|
583
|
-
*
|
|
604
|
+
* ---------------------------------------------------------------------------------
|
|
584
605
|
* **This function is an **assertion function**.**
|
|
606
|
+
*
|
|
585
607
|
* - **Behavior:**
|
|
586
|
-
*
|
|
587
|
-
*
|
|
588
|
-
*
|
|
589
|
-
*
|
|
590
|
-
*
|
|
591
|
-
*
|
|
608
|
+
* - Validates that the given `value` is a **plain-object**.
|
|
609
|
+
* - After it returns successfully, TypeScript narrows the type of `value` to `plain-object` **(generic support)**.
|
|
610
|
+
* - If `value` is a `plain-object` ➔ execution continues normally.
|
|
611
|
+
* - If `value` is not a `plain-object` ➔ throws a built-in error with either:
|
|
612
|
+
* - A custom error message (`options.message`), or
|
|
613
|
+
* - A default message including the actual type.
|
|
592
614
|
* - **A valid `plain object` is:**
|
|
593
|
-
*
|
|
594
|
-
*
|
|
595
|
-
*
|
|
596
|
-
*
|
|
597
|
-
*
|
|
598
|
-
*
|
|
599
|
-
*
|
|
600
|
-
*
|
|
601
|
-
*
|
|
602
|
-
*
|
|
603
|
-
*
|
|
604
|
-
*
|
|
605
|
-
*
|
|
606
|
-
* -
|
|
607
|
-
*
|
|
608
|
-
*
|
|
609
|
-
*
|
|
610
|
-
*
|
|
611
|
-
*
|
|
612
|
-
*
|
|
613
|
-
*
|
|
614
|
-
*
|
|
615
|
-
*
|
|
616
|
-
*
|
|
615
|
+
* - Created by the `Object` constructor, or
|
|
616
|
+
* - Has a `[[Prototype]]` of `null` (e.g. `Object.create(null)`).
|
|
617
|
+
* - **Returns `undefined` (valid) for:**
|
|
618
|
+
* - Empty object literals: `{}`
|
|
619
|
+
* - Objects with null prototype: `Object.create(null)`
|
|
620
|
+
* - **Returns `throws` for:**
|
|
621
|
+
* - Arrays (`[]`, `new Array()`)
|
|
622
|
+
* - Functions (regular, arrow, or class constructors)
|
|
623
|
+
* - Built-in objects: `Date`, `RegExp`, `Error`, `Map`, `Set`, `WeakMap`, `WeakSet`
|
|
624
|
+
* - Boxed primitives: `new String()`, `new Number()`, `new Boolean()`
|
|
625
|
+
* - `null` or `undefined`
|
|
626
|
+
* - Symbols
|
|
627
|
+
* - Class instances
|
|
628
|
+
* - **Error type selection (`options.errorType`):**
|
|
629
|
+
* - You can override the type of error thrown when validation fails.
|
|
630
|
+
* - Must be one of the standard JavaScript built-in errors:
|
|
631
|
+
* - [`TypeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError) |
|
|
632
|
+
* [`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) |
|
|
633
|
+
* [`EvalError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/EvalError) |
|
|
634
|
+
* [`RangeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RangeError) |
|
|
635
|
+
* [`ReferenceError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ReferenceError) |
|
|
636
|
+
* [`SyntaxError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SyntaxError) |
|
|
637
|
+
* [`URIError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/URIError).
|
|
638
|
+
* - **Default:** `"TypeError"` if not provided or invalid.
|
|
639
|
+
*
|
|
617
640
|
* @template T - The input type being asserted.
|
|
618
641
|
* @param {*} value - ***The value to validate.***
|
|
619
642
|
* @param {OptionsAssertIs} [options]
|
|
620
643
|
* ***Optional configuration:***
|
|
621
|
-
*
|
|
622
|
-
*
|
|
623
|
-
*
|
|
624
|
-
*
|
|
625
|
-
*
|
|
644
|
+
* - `message`: A custom error message (`string` or `function`).
|
|
645
|
+
* - `errorType`: Built-in JavaScript error type to throw on failure (default `"TypeError"`).
|
|
646
|
+
* - `formatCase`: Controls how detected type names are formatted case in error messages.
|
|
647
|
+
* - `useAcronyms`: Control uppercase preservation of recognized acronyms during formatting.
|
|
648
|
+
*
|
|
626
649
|
* @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 `value` is not a plain-object.
|
|
650
|
+
* @returns {boolean} Narrows `value` to a `plain-object` **(generic support)** if no error is thrown.
|
|
651
|
+
*
|
|
627
652
|
* @example
|
|
628
653
|
* ```ts
|
|
629
654
|
* // ✅ Simple usage
|
|
@@ -703,40 +728,44 @@ declare function assertIsArray(value: unknown, options?: OptionsAssertIs): asser
|
|
|
703
728
|
* ```
|
|
704
729
|
*/
|
|
705
730
|
declare function assertIsPlainObject<T>(value: T, options?: OptionsAssertIs): asserts value is IsPlainObjectResult<T>;
|
|
706
|
-
/**
|
|
731
|
+
/** --------------------------------------------------------------------------------
|
|
707
732
|
* * ***Type guard assertion: `assertIsString`.***
|
|
708
|
-
*
|
|
733
|
+
* ---------------------------------------------------------------------------------
|
|
709
734
|
* **This function is an **assertion function**.**
|
|
735
|
+
*
|
|
710
736
|
* - **Behavior:**
|
|
711
|
-
*
|
|
712
|
-
*
|
|
713
|
-
*
|
|
714
|
-
*
|
|
715
|
-
*
|
|
716
|
-
*
|
|
717
|
-
* -
|
|
718
|
-
*
|
|
719
|
-
*
|
|
720
|
-
* -
|
|
721
|
-
*
|
|
722
|
-
*
|
|
723
|
-
*
|
|
724
|
-
*
|
|
725
|
-
*
|
|
726
|
-
*
|
|
727
|
-
*
|
|
728
|
-
*
|
|
729
|
-
*
|
|
730
|
-
*
|
|
737
|
+
* - Validates that the given `value` is a **primitive-string**.
|
|
738
|
+
* - After it returns successfully, TypeScript narrows the type of `value` to `primitive-string`.
|
|
739
|
+
* - If `value` is a `primitive-string` ➔ execution continues normally.
|
|
740
|
+
* - If `value` is not a `primitive-string` ➔ throws a built-in error with either:
|
|
741
|
+
* - A custom error message (`options.message`), or
|
|
742
|
+
* - A default message including the actual type.
|
|
743
|
+
* - **Note:**
|
|
744
|
+
* - A "string" refers strictly to a JavaScript `primitive-string` type (e.g., `"hello"`, `""`, `"123"`).
|
|
745
|
+
* - This function excludes `String` objects created with `new String()`.
|
|
746
|
+
* - **Error type selection (`options.errorType`):**
|
|
747
|
+
* - You can override the type of error thrown when validation fails.
|
|
748
|
+
* - Must be one of the standard JavaScript built-in errors:
|
|
749
|
+
* - [`TypeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError) |
|
|
750
|
+
* [`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) |
|
|
751
|
+
* [`EvalError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/EvalError) |
|
|
752
|
+
* [`RangeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RangeError) |
|
|
753
|
+
* [`ReferenceError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ReferenceError) |
|
|
754
|
+
* [`SyntaxError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SyntaxError) |
|
|
755
|
+
* [`URIError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/URIError).
|
|
756
|
+
* - **Default:** `"TypeError"` if not provided or invalid.
|
|
757
|
+
*
|
|
731
758
|
* @param {*} value - ***The value to validate.***
|
|
732
759
|
* @param {OptionsAssertIs} [options]
|
|
733
760
|
* ***Optional configuration:***
|
|
734
|
-
*
|
|
735
|
-
*
|
|
736
|
-
*
|
|
737
|
-
*
|
|
738
|
-
*
|
|
761
|
+
* - `message`: A custom error message (`string` or `function`).
|
|
762
|
+
* - `errorType`: Built-in JavaScript error type to throw on failure (default `"TypeError"`).
|
|
763
|
+
* - `formatCase`: Controls how detected type names are formatted case in error messages.
|
|
764
|
+
* - `useAcronyms`: Control uppercase preservation of recognized acronyms during formatting.
|
|
765
|
+
*
|
|
739
766
|
* @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 primitive string.
|
|
767
|
+
* @returns {boolean} Narrows `value` to `string` if no error is thrown.
|
|
768
|
+
*
|
|
740
769
|
* @example
|
|
741
770
|
* ```ts
|
|
742
771
|
* // ✅ Simple usage
|