@rzl-zone/utils-js 3.13.0-beta.3 → 3.13.1-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.references/index.d.cts +1 -1
- package/dist/.references/index.d.ts +1 -1
- package/dist/{assertIsArray-DWsgvahU.cjs → assertIsArray-CqIFmlgj.cjs} +3 -3
- package/dist/{assertIsArray-DWsgvahU.cjs.map → assertIsArray-CqIFmlgj.cjs.map} +1 -1
- package/dist/{assertIsArray-C2rkhR9M.js → assertIsArray-DrLORH0Y.js} +3 -3
- package/dist/{assertIsArray-C2rkhR9M.js.map → assertIsArray-DrLORH0Y.js.map} +1 -1
- package/dist/{assertIsBoolean-BKcvET7Z.cjs → assertIsBoolean-CEx4KbHg.cjs} +2 -2
- package/dist/{assertIsBoolean-BKcvET7Z.cjs.map → assertIsBoolean-CEx4KbHg.cjs.map} +1 -1
- package/dist/{assertIsBoolean-Clc7Vw4v.js → assertIsBoolean-DDhQ2D-k.js} +2 -2
- package/dist/{assertIsBoolean-Clc7Vw4v.js.map → assertIsBoolean-DDhQ2D-k.js.map} +1 -1
- package/dist/{assertIsString-Ddz4y81W.js → assertIsString-1iLqxrN0.js} +3 -3
- package/dist/{assertIsString-Ddz4y81W.js.map → assertIsString-1iLqxrN0.js.map} +1 -1
- package/dist/{assertIsString-DxIqUfF1.cjs → assertIsString-DGDLC-XD.cjs} +3 -3
- package/dist/{assertIsString-DxIqUfF1.cjs.map → assertIsString-DGDLC-XD.cjs.map} +1 -1
- package/dist/assertions/index.cjs +5 -5
- 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 +5 -5
- 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-Bu5c_RZ9.cjs → conversions-Bxa01uIl.cjs} +12 -12
- package/dist/{conversions-Bu5c_RZ9.cjs.map → conversions-Bxa01uIl.cjs.map} +1 -1
- package/dist/{conversions-DjfhrQE9.js → conversions-CA_3PTAH.js} +12 -12
- package/dist/{conversions-DjfhrQE9.js.map → conversions-CA_3PTAH.js.map} +1 -1
- package/dist/events/index.cjs +4 -4
- package/dist/events/index.cjs.map +1 -1
- package/dist/events/index.d.cts +1 -1
- package/dist/events/index.d.ts +1 -1
- package/dist/events/index.js +4 -4
- package/dist/events/index.js.map +1 -1
- 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-CidRTj87.js → formatters-Bm3a_akj.js} +10 -10
- package/dist/{formatters-CidRTj87.js.map → formatters-Bm3a_akj.js.map} +1 -1
- package/dist/{formatters-DF4887ia.cjs → formatters-Bt6QuhxK.cjs} +10 -10
- package/dist/{formatters-DF4887ia.cjs.map → formatters-Bt6QuhxK.cjs.map} +1 -1
- package/dist/generators/index.cjs +5 -5
- 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 +5 -5
- package/dist/generators/index.js.map +1 -1
- package/dist/{index-DPBypj6v.d.ts → index--h04HuBE.d.cts} +1 -1
- package/dist/{index-CyZz4BHD.d.cts → index--h04HuBE.d.ts} +1 -1
- package/dist/{index-CX8gCrW8.d.ts → index-Ap8U-8Qx.d.cts} +3 -3
- package/dist/{index-DC7eXTo_.d.cts → index-BAeeggeh.d.cts} +1 -1
- package/dist/{index-BZMwAuLf.d.ts → index-BAeeggeh.d.ts} +1 -1
- package/dist/{index-BK86Fnvd.d.ts → index-Bm5odgLW.d.ts} +2 -2
- package/dist/{index-CHwf6vUh.d.ts → index-BqkYm8qT.d.cts} +1 -1
- package/dist/{index-CIBhF2hQ.d.cts → index-BqkYm8qT.d.ts} +1 -1
- package/dist/{index-CWgiyaU3.d.cts → index-CJx0EFQ4.d.cts} +2 -2
- package/dist/{index-Cyu3Mh3N.d.cts → index-CMglhpFG.d.ts} +3 -3
- package/dist/{index-Dq5vUFfH.d.ts → index-CakviK5E.d.cts} +2 -2
- package/dist/{index-YeyLvCAr.d.cts → index-D5nTp1kV.d.ts} +2 -2
- package/dist/{index-C02XatNH.d.ts → index-hOCUw-B9.d.ts} +2 -2
- package/dist/{index-BbCX319b.d.cts → index-uaHl0X-r.d.cts} +2 -2
- package/dist/{isBigInt-BePsmNsm.cjs → isBigInt-CqZNWVtI.cjs} +2 -2
- package/dist/{isBigInt-BePsmNsm.cjs.map → isBigInt-CqZNWVtI.cjs.map} +1 -1
- package/dist/{isBigInt-Cx4j_cju.js → isBigInt-f6yY2fAV.js} +2 -2
- package/dist/{isBigInt-Cx4j_cju.js.map → isBigInt-f6yY2fAV.js.map} +1 -1
- package/dist/{isEmptyObject-Dp4pCGTa.js → isEmptyObject-BYNnSKzw.js} +3 -3
- package/dist/{isEmptyObject-Dp4pCGTa.js.map → isEmptyObject-BYNnSKzw.js.map} +1 -1
- package/dist/{isEmptyObject-DYypq92-.cjs → isEmptyObject-C2lQyFZS.cjs} +3 -3
- package/dist/{isEmptyObject-DYypq92-.cjs.map → isEmptyObject-C2lQyFZS.cjs.map} +1 -1
- package/dist/{isEmptyString-CzY-9G-x.cjs → isEmptyString-DNMPmS-H.cjs} +3 -3
- package/dist/{isEmptyString-CzY-9G-x.cjs.map → isEmptyString-DNMPmS-H.cjs.map} +1 -1
- package/dist/{isEmptyString-BXgKFQxw.js → isEmptyString-Ga77_3Q1.js} +3 -3
- package/dist/{isEmptyString-BXgKFQxw.js.map → isEmptyString-Ga77_3Q1.js.map} +1 -1
- package/dist/{isEmptyValue-B7Zd9DI3.js → isEmptyValue-D7-6WWS9.js} +5 -5
- package/dist/{isEmptyValue-B7Zd9DI3.js.map → isEmptyValue-D7-6WWS9.js.map} +1 -1
- package/dist/{isEmptyValue-Ci3kVU4E.cjs → isEmptyValue-DZaDHEIw.cjs} +5 -5
- package/dist/{isEmptyValue-Ci3kVU4E.cjs.map → isEmptyValue-DZaDHEIw.cjs.map} +1 -1
- package/dist/{isEqual-Bd7mClU4.cjs → isEqual-D8W3Wizi.cjs} +4 -4
- package/dist/{isEqual-Bd7mClU4.cjs.map → isEqual-D8W3Wizi.cjs.map} +1 -1
- package/dist/{isEqual-CylDBGUr.js → isEqual-ekId-j5b.js} +4 -4
- package/dist/{isEqual-CylDBGUr.js.map → isEqual-ekId-j5b.js.map} +1 -1
- package/dist/{isFinite-CZ-Aiy4T.js → isFinite-BJO7Dt6B.js} +3 -3
- package/dist/{isFinite-CZ-Aiy4T.js.map → isFinite-BJO7Dt6B.js.map} +1 -1
- package/dist/{isFinite-D8jhlqPf.cjs → isFinite-Crw95XV8.cjs} +3 -3
- package/dist/{isFinite-D8jhlqPf.cjs.map → isFinite-Crw95XV8.cjs.map} +1 -1
- package/dist/{isInteger-DK_0nvNU.js → isInteger-B75voxys.js} +2 -2
- package/dist/{isInteger-DK_0nvNU.js.map → isInteger-B75voxys.js.map} +1 -1
- package/dist/{isInteger-CCJhQ1Mx.cjs → isInteger-CSMNm--9.cjs} +2 -2
- package/dist/{isInteger-CCJhQ1Mx.cjs.map → isInteger-CSMNm--9.cjs.map} +1 -1
- package/dist/{isPlainObject-DtduwtUp.d.ts → isPlainObject-ByfuseCf.d.cts} +1 -1
- package/dist/{isPlainObject-BGg8uHeL.d.cts → isPlainObject-ByfuseCf.d.ts} +1 -1
- package/dist/{isServer-C2YtJlD1.js → isServer-BHOSvBhV.js} +2 -2
- package/dist/{isServer-C2YtJlD1.js.map → isServer-BHOSvBhV.js.map} +1 -1
- package/dist/{isServer-CT9EkFKG.cjs → isServer-HA13Dzo2.cjs} +2 -2
- package/dist/{isServer-CT9EkFKG.cjs.map → isServer-HA13Dzo2.cjs.map} +1 -1
- package/dist/{isTypedArray-BT7YP1S9.cjs → isTypedArray-CWlHRz_O.cjs} +3 -3
- package/dist/{isTypedArray-BT7YP1S9.cjs.map → isTypedArray-CWlHRz_O.cjs.map} +1 -1
- package/dist/{isTypedArray-hcngU0pK.js → isTypedArray-CmnQ7Yx9.js} +3 -3
- package/dist/{isTypedArray-hcngU0pK.js.map → isTypedArray-CmnQ7Yx9.js.map} +1 -1
- package/dist/{isValidDomain-BCN5-tj9.js → isValidDomain-BqyLVi7S.js} +6 -6
- package/dist/isValidDomain-BqyLVi7S.js.map +1 -0
- package/dist/{isValidDomain-CXWNcRo6.cjs → isValidDomain-ByrOfQsh.cjs} +6 -6
- package/dist/isValidDomain-ByrOfQsh.cjs.map +1 -0
- package/dist/{noop-D4tT7tWN.cjs → noop-CkwxErJ2.cjs} +2 -2
- package/dist/{noop-D4tT7tWN.cjs.map → noop-CkwxErJ2.cjs.map} +1 -1
- package/dist/{noop-BDfC9Zq4.js → noop-D_Ots__Z.js} +2 -2
- package/dist/{noop-BDfC9Zq4.js.map → noop-D_Ots__Z.js.map} +1 -1
- package/dist/{normalizeSpaces-BTXDP8vZ.cjs → normalizeSpaces-88yaixiu.cjs} +3 -3
- package/dist/{normalizeSpaces-BTXDP8vZ.cjs.map → normalizeSpaces-88yaixiu.cjs.map} +1 -1
- package/dist/{normalizeSpaces-B289eKyK.js → normalizeSpaces-Cat8CHtt.js} +3 -3
- package/dist/{normalizeSpaces-B289eKyK.js.map → normalizeSpaces-Cat8CHtt.js.map} +1 -1
- package/dist/operations/index.cjs +7 -7
- package/dist/operations/index.cjs.map +1 -1
- package/dist/operations/index.d.cts +1 -1
- package/dist/operations/index.d.ts +1 -1
- package/dist/operations/index.js +7 -7
- package/dist/operations/index.js.map +1 -1
- package/dist/parsers/index.cjs +2 -2
- package/dist/parsers/index.d.cts +1 -1
- package/dist/parsers/index.d.ts +1 -1
- package/dist/parsers/index.js +2 -2
- package/dist/{parsers-CNag9LsX.js → parsers-BLHzVoh-.js} +4 -4
- package/dist/{parsers-CNag9LsX.js.map → parsers-BLHzVoh-.js.map} +1 -1
- package/dist/{parsers-5G1Lface.cjs → parsers-xAQmKCgS.cjs} +4 -4
- package/dist/{parsers-5G1Lface.cjs.map → parsers-xAQmKCgS.cjs.map} +1 -1
- package/dist/{parsing-CobzHooQ.js → parsing-BYo6U0EG.js} +3 -3
- package/dist/{parsing-CobzHooQ.js.map → parsing-BYo6U0EG.js.map} +1 -1
- package/dist/{parsing-B6vxp2h8.cjs → parsing-CuezVd0e.cjs} +3 -3
- package/dist/{parsing-B6vxp2h8.cjs.map → parsing-CuezVd0e.cjs.map} +1 -1
- package/dist/predicates/index.cjs +14 -14
- 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-DvLryz_b.js → predicates-BMTIIYx8.js} +11 -11
- package/dist/{predicates-DvLryz_b.js.map → predicates-BMTIIYx8.js.map} +1 -1
- package/dist/{predicates-DlID4Pks.cjs → predicates-ZmZpelMh.cjs} +11 -11
- package/dist/{predicates-DlID4Pks.cjs.map → predicates-ZmZpelMh.cjs.map} +1 -1
- package/dist/promises/index.cjs +4 -4
- package/dist/promises/index.cjs.map +1 -1
- package/dist/promises/index.d.cts +1 -1
- package/dist/promises/index.d.ts +1 -1
- package/dist/promises/index.js +4 -4
- package/dist/promises/index.js.map +1 -1
- package/dist/{punyCode-GakZYPCT.js → punyCode-COTqgXMJ.js} +6 -6
- package/dist/{punyCode-GakZYPCT.js.map → punyCode-COTqgXMJ.js.map} +1 -1
- package/dist/{punyCode-DaBFrfga.cjs → punyCode-WZ6-GaTM.cjs} +6 -6
- package/dist/{punyCode-DaBFrfga.cjs.map → punyCode-WZ6-GaTM.cjs.map} +1 -1
- package/dist/{removeSpaces-DhJ1haaH.cjs → removeSpaces-BeGkktUl.cjs} +3 -3
- package/dist/{removeSpaces-DhJ1haaH.cjs.map → removeSpaces-BeGkktUl.cjs.map} +1 -1
- package/dist/{removeSpaces-BJ-zNnJq.js → removeSpaces-CQJvw1yU.js} +3 -3
- package/dist/{removeSpaces-BJ-zNnJq.js.map → removeSpaces-CQJvw1yU.js.map} +1 -1
- package/dist/rzl-utils.global.js +13 -13
- package/dist/{safeJsonParse-DiWBPfaE.cjs → safeJsonParse-BznDD3fi.cjs} +6 -6
- package/dist/{safeJsonParse-DiWBPfaE.cjs.map → safeJsonParse-BznDD3fi.cjs.map} +1 -1
- package/dist/{safeJsonParse-bcBYPjeb.js → safeJsonParse-D8H3wCv7.js} +6 -6
- package/dist/{safeJsonParse-bcBYPjeb.js.map → safeJsonParse-D8H3wCv7.js.map} +1 -1
- package/dist/{safeStableStringify-DSwcrPll.cjs → safeStableStringify-4b-E_UHM.cjs} +4 -4
- package/dist/{safeStableStringify-DSwcrPll.cjs.map → safeStableStringify-4b-E_UHM.cjs.map} +1 -1
- package/dist/{safeStableStringify-C1SA52w7.js → safeStableStringify-BLwA1VC-.js} +4 -4
- package/dist/{safeStableStringify-C1SA52w7.js.map → safeStableStringify-BLwA1VC-.js.map} +1 -1
- package/dist/strings/index.cjs +5 -5
- 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 +5 -5
- package/dist/strings/index.js.map +1 -1
- package/dist/tailwind/index.cjs +2 -2
- package/dist/tailwind/index.d.cts +2 -2
- package/dist/tailwind/index.d.ts +2 -2
- package/dist/tailwind/index.js +2 -2
- package/dist/{tailwind-DMPTwJ0X.cjs → tailwind-CjxdO7aL.cjs} +5 -5
- package/dist/{tailwind-DMPTwJ0X.cjs.map → tailwind-CjxdO7aL.cjs.map} +1 -1
- package/dist/{tailwind-D62asDBR.js → tailwind-RSE3obLb.js} +5 -5
- package/dist/{tailwind-D62asDBR.js.map → tailwind-RSE3obLb.js.map} +1 -1
- package/dist/{toStringArrayUnRecursive-DJ8JBO3N.cjs → toStringArrayUnRecursive-D-jHROts.cjs} +6 -6
- package/dist/{toStringArrayUnRecursive-DJ8JBO3N.cjs.map → toStringArrayUnRecursive-D-jHROts.cjs.map} +1 -1
- package/dist/{toStringArrayUnRecursive-DBicbWv8.js → toStringArrayUnRecursive-NreW1dyV.js} +6 -6
- package/dist/{toStringArrayUnRecursive-DBicbWv8.js.map → toStringArrayUnRecursive-NreW1dyV.js.map} +1 -1
- package/dist/urls/index.cjs +3 -3
- package/dist/urls/index.d.cts +1 -1
- package/dist/urls/index.d.ts +1 -1
- package/dist/urls/index.js +3 -3
- package/dist/{urls-DCjjZNTH.cjs → urls-C6BvhrrV.cjs} +11 -11
- package/dist/{urls-DCjjZNTH.cjs.map → urls-C6BvhrrV.cjs.map} +1 -1
- package/dist/{urls-DTndjYDD.js → urls-CLVfEB7O.js} +11 -11
- package/dist/{urls-DTndjYDD.js.map → urls-CLVfEB7O.js.map} +1 -1
- package/package.json +5 -5
- package/dist/isValidDomain-BCN5-tj9.js.map +0 -1
- package/dist/isValidDomain-CXWNcRo6.cjs.map +0 -1
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
* ========================================================================
|
|
3
3
|
* @rzl-zone/utils-js
|
|
4
4
|
* ------------------------------------------------------------------------
|
|
5
|
-
* Version: `3.13.
|
|
5
|
+
* Version: `3.13.1-beta.0`
|
|
6
6
|
* Author: `Rizalvin Dwiky <rizalvindwiky@gmail.com>`
|
|
7
7
|
* Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/utils-js`
|
|
8
8
|
* ========================================================================
|
|
9
9
|
*/
|
|
10
|
-
import { k as isString, n as resolveErrorMessageAssertions } from "./assertIsBoolean-
|
|
10
|
+
import { k as isString, n as resolveErrorMessageAssertions } from "./assertIsBoolean-DDhQ2D-k.js";
|
|
11
11
|
const assertIsString = (value, options = {}) => {
|
|
12
12
|
if (isString(value)) return;
|
|
13
13
|
resolveErrorMessageAssertions({
|
|
@@ -17,4 +17,4 @@ const assertIsString = (value, options = {}) => {
|
|
|
17
17
|
});
|
|
18
18
|
};
|
|
19
19
|
export { assertIsString as t };
|
|
20
|
-
//# sourceMappingURL=assertIsString-
|
|
20
|
+
//# sourceMappingURL=assertIsString-1iLqxrN0.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assertIsString-
|
|
1
|
+
{"version":3,"file":"assertIsString-1iLqxrN0.js","names":[],"sources":["../src/assertions/strings/assertIsString.ts"],"sourcesContent":["import { isString } from \"@/predicates/is/isString\";\nimport {\n resolveErrorMessageAssertions,\n type OptionsAssertIs\n} from \"../_private/assertIs\";\n\n/** -------------------------------------------------------\n * * ***Type guard assertion: `assertIsString`.***\n * -------------------------------------------------------\n * **This function is an **assertion function**.**\n * - **Behavior:**\n * - Validates that the given `value` is a **primitive-string**.\n * - After it returns successfully, TypeScript narrows the type of `value` to `primitive-string`.\n * - ✅ If `value` is a `primitive-string` ➔ execution continues normally.\n * - ❌ If `value` is not a `primitive-string` ➔ 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 \"string\" refers strictly to a JavaScript `primitive-string` type (e.g., `\"hello\"`, `\"\"`, `\"123\"`).\n * - This function excludes `String` objects created with `new String()`.\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 `string` 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 primitive string.\n * @example\n * ```ts\n * // ✅ Simple usage\n * assertIsString(\"hello\");\n * // No error, value is string\n *\n * // ❌ Throws TypeError (default behavior)\n * // Case 1: Invalid input type — received a string instead of a string\n * assertIsString(42);\n * // ➔ TypeError: \"Parameter input (`value`) must be of type `string`, but received: `number`.\"\n *\n * // Case 3: The new String() is a String object (constructor), not a primitive string\n * assertIsString(new String(\"abc\"));\n * // ➔ TypeError: \"Parameter input (`value`) must be of type `string`, but received: `string-constructor`.\"\n *\n * // ❌ Throws custom error type (e.g., RangeError)\n * assertIsString(async function () {}, { errorType: \"RangeError\" });\n * // ➔ RangeError: \"Parameter input (`value`) must be of type `string`, but received: `async-function`.\"\n *\n * // ❌ Throws a TypeError with a custom string static message\n * assertIsString(123, { message: \"Must be a string!\" });\n * // ➔ TypeError: \"Must be a string!\"\n *\n * // ❌ Throws a TypeError with a custom message function and formatCase\n * assertIsString(/regex/, {\n * message: ({ currentType, validType }) => {\n * return `Expected ${validType} but got (${currentType}).`\n * },\n * formatCase: \"toPascalCaseSpace\"\n * });\n * // ➔ TypeError: \"Expected string but got (Reg Exp).\"\n *\n * // ❌ Throws a TypeError with a custom useAcronyms option\n * // Case 1:\n * assertIsString(new URL(\"https://example.com\"),{\n * message: ({ currentType, validType }) => {\n * return `Expected ${validType} but got (${currentType}).`\n * },\n * });\n * // ➔ TypeError: \"Expected string but got (url).\"\n * assertIsString(new URL(\"https://example.com\"), {\n * useAcronyms: true,\n * message: ({ currentType, validType }) => {\n * return `Expected ${validType} but got (${currentType}).`\n * },\n * });\n * // ➔ TypeError: \"Expected string but got (URL).\"\n *\n * // Case 2:\n * assertIsString(new URLSearchParams, {\n * formatCase: \"toPascalCase\",\n * message: ({ currentType, validType }) => {\n * return `Expected ${validType} but got (${currentType}).`\n * },\n * });\n * // ➔ TypeError: \"Expected string but got (UrlSearchParams).\"\n * assertIsString(new URLSearchParams, {\n * useAcronyms: true,\n * formatCase: \"toPascalCase\",\n * message: ({ currentType, validType }) => {\n * return `Expected ${validType} but got (${currentType}).`\n * },\n * });\n * // ➔ TypeError: \"Expected string but got (URLSearchParams).\"\n * ```\n * -------------------------------------------------------\n * ✅ ***Real-world usage with generic narrowing***:\n * ```ts\n * const mixedValue: string | boolean | undefined = getUserInput();\n *\n * // Runtime assertion: throws if `mixedValue` is not a `string`\n * assertIsString(mixedValue, {\n * errorType: \"RangeError\",\n * message: \"Must be a string!\"\n * });\n *\n * // ✅ If no error thrown, TypeScript narrows `mixedValue` to `string` here\n * const result: string = mixedValue; // ➔ Safe type assignment\n * console.log(result.toUpperCase()); // ➔ Safe to call String.prototype methods\n * ```\n */\nexport const assertIsString: (\n value: unknown,\n options?: OptionsAssertIs\n) => asserts value is string = (\n value: unknown,\n options: OptionsAssertIs = {}\n): asserts value is string => {\n if (isString(value)) return;\n\n resolveErrorMessageAssertions({\n value,\n options,\n requiredValidType: \"string\"\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyHA,MAAa,kBAIX,OACA,UAA2B,CAAC,MACA;CAC5B,IAAI,SAAS,KAAK,GAAG;CAErB,8BAA8B;EAC5B;EACA;EACA,mBAAmB;CACrB,CAAC;AACH"}
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
* ========================================================================
|
|
3
3
|
* @rzl-zone/utils-js
|
|
4
4
|
* ------------------------------------------------------------------------
|
|
5
|
-
* Version: `3.13.
|
|
5
|
+
* Version: `3.13.1-beta.0`
|
|
6
6
|
* Author: `Rizalvin Dwiky <rizalvindwiky@gmail.com>`
|
|
7
7
|
* Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/utils-js`
|
|
8
8
|
* ========================================================================
|
|
9
9
|
*/
|
|
10
10
|
"use strict";
|
|
11
|
-
const require_assertIsBoolean = require('./assertIsBoolean-
|
|
11
|
+
const require_assertIsBoolean = require('./assertIsBoolean-CEx4KbHg.cjs');
|
|
12
12
|
const assertIsString = (value, options = {}) => {
|
|
13
13
|
if (require_assertIsBoolean.isString(value)) return;
|
|
14
14
|
require_assertIsBoolean.resolveErrorMessageAssertions({
|
|
@@ -23,4 +23,4 @@ Object.defineProperty(exports, 'assertIsString', {
|
|
|
23
23
|
return assertIsString;
|
|
24
24
|
}
|
|
25
25
|
});
|
|
26
|
-
//# sourceMappingURL=assertIsString-
|
|
26
|
+
//# sourceMappingURL=assertIsString-DGDLC-XD.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assertIsString-
|
|
1
|
+
{"version":3,"file":"assertIsString-DGDLC-XD.cjs","names":["isString"],"sources":["../src/assertions/strings/assertIsString.ts"],"sourcesContent":["import { isString } from \"@/predicates/is/isString\";\nimport {\n resolveErrorMessageAssertions,\n type OptionsAssertIs\n} from \"../_private/assertIs\";\n\n/** -------------------------------------------------------\n * * ***Type guard assertion: `assertIsString`.***\n * -------------------------------------------------------\n * **This function is an **assertion function**.**\n * - **Behavior:**\n * - Validates that the given `value` is a **primitive-string**.\n * - After it returns successfully, TypeScript narrows the type of `value` to `primitive-string`.\n * - ✅ If `value` is a `primitive-string` ➔ execution continues normally.\n * - ❌ If `value` is not a `primitive-string` ➔ 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 \"string\" refers strictly to a JavaScript `primitive-string` type (e.g., `\"hello\"`, `\"\"`, `\"123\"`).\n * - This function excludes `String` objects created with `new String()`.\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 `string` 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 primitive string.\n * @example\n * ```ts\n * // ✅ Simple usage\n * assertIsString(\"hello\");\n * // No error, value is string\n *\n * // ❌ Throws TypeError (default behavior)\n * // Case 1: Invalid input type — received a string instead of a string\n * assertIsString(42);\n * // ➔ TypeError: \"Parameter input (`value`) must be of type `string`, but received: `number`.\"\n *\n * // Case 3: The new String() is a String object (constructor), not a primitive string\n * assertIsString(new String(\"abc\"));\n * // ➔ TypeError: \"Parameter input (`value`) must be of type `string`, but received: `string-constructor`.\"\n *\n * // ❌ Throws custom error type (e.g., RangeError)\n * assertIsString(async function () {}, { errorType: \"RangeError\" });\n * // ➔ RangeError: \"Parameter input (`value`) must be of type `string`, but received: `async-function`.\"\n *\n * // ❌ Throws a TypeError with a custom string static message\n * assertIsString(123, { message: \"Must be a string!\" });\n * // ➔ TypeError: \"Must be a string!\"\n *\n * // ❌ Throws a TypeError with a custom message function and formatCase\n * assertIsString(/regex/, {\n * message: ({ currentType, validType }) => {\n * return `Expected ${validType} but got (${currentType}).`\n * },\n * formatCase: \"toPascalCaseSpace\"\n * });\n * // ➔ TypeError: \"Expected string but got (Reg Exp).\"\n *\n * // ❌ Throws a TypeError with a custom useAcronyms option\n * // Case 1:\n * assertIsString(new URL(\"https://example.com\"),{\n * message: ({ currentType, validType }) => {\n * return `Expected ${validType} but got (${currentType}).`\n * },\n * });\n * // ➔ TypeError: \"Expected string but got (url).\"\n * assertIsString(new URL(\"https://example.com\"), {\n * useAcronyms: true,\n * message: ({ currentType, validType }) => {\n * return `Expected ${validType} but got (${currentType}).`\n * },\n * });\n * // ➔ TypeError: \"Expected string but got (URL).\"\n *\n * // Case 2:\n * assertIsString(new URLSearchParams, {\n * formatCase: \"toPascalCase\",\n * message: ({ currentType, validType }) => {\n * return `Expected ${validType} but got (${currentType}).`\n * },\n * });\n * // ➔ TypeError: \"Expected string but got (UrlSearchParams).\"\n * assertIsString(new URLSearchParams, {\n * useAcronyms: true,\n * formatCase: \"toPascalCase\",\n * message: ({ currentType, validType }) => {\n * return `Expected ${validType} but got (${currentType}).`\n * },\n * });\n * // ➔ TypeError: \"Expected string but got (URLSearchParams).\"\n * ```\n * -------------------------------------------------------\n * ✅ ***Real-world usage with generic narrowing***:\n * ```ts\n * const mixedValue: string | boolean | undefined = getUserInput();\n *\n * // Runtime assertion: throws if `mixedValue` is not a `string`\n * assertIsString(mixedValue, {\n * errorType: \"RangeError\",\n * message: \"Must be a string!\"\n * });\n *\n * // ✅ If no error thrown, TypeScript narrows `mixedValue` to `string` here\n * const result: string = mixedValue; // ➔ Safe type assignment\n * console.log(result.toUpperCase()); // ➔ Safe to call String.prototype methods\n * ```\n */\nexport const assertIsString: (\n value: unknown,\n options?: OptionsAssertIs\n) => asserts value is string = (\n value: unknown,\n options: OptionsAssertIs = {}\n): asserts value is string => {\n if (isString(value)) return;\n\n resolveErrorMessageAssertions({\n value,\n options,\n requiredValidType: \"string\"\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyHA,MAAa,kBAIX,OACA,UAA2B,CAAC,MACA;CAC5B,IAAIA,iCAAS,KAAK,GAAG;CAErB,sDAA8B;EAC5B;EACA;EACA,mBAAmB;CACrB,CAAC;AACH"}
|
|
@@ -2,17 +2,17 @@
|
|
|
2
2
|
* ========================================================================
|
|
3
3
|
* @rzl-zone/utils-js
|
|
4
4
|
* ------------------------------------------------------------------------
|
|
5
|
-
* Version: `3.13.
|
|
5
|
+
* Version: `3.13.1-beta.0`
|
|
6
6
|
* Author: `Rizalvin Dwiky <rizalvindwiky@gmail.com>`
|
|
7
7
|
* Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/utils-js`
|
|
8
8
|
* ========================================================================
|
|
9
9
|
*/
|
|
10
10
|
"use strict";
|
|
11
11
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
12
|
-
const require_assertIsBoolean = require('../assertIsBoolean-
|
|
13
|
-
const require_isBigInt = require('../isBigInt-
|
|
14
|
-
const require_assertIsArray = require('../assertIsArray-
|
|
15
|
-
const require_assertIsString = require('../assertIsString-
|
|
12
|
+
const require_assertIsBoolean = require('../assertIsBoolean-CEx4KbHg.cjs');
|
|
13
|
+
const require_isBigInt = require('../isBigInt-CqZNWVtI.cjs');
|
|
14
|
+
const require_assertIsArray = require('../assertIsArray-CqIFmlgj.cjs');
|
|
15
|
+
const require_assertIsString = require('../assertIsString-DGDLC-XD.cjs');
|
|
16
16
|
const assertIsBigInt = (value, options = {}) => {
|
|
17
17
|
if (require_isBigInt.isBigInt(value)) return;
|
|
18
18
|
require_assertIsBoolean.resolveErrorMessageAssertions({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["isBigInt","isNumber","hasOwnProp"],"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,EAAE,KACD;CAC5B,IAAIA,0BAAS,MAAM,EAAE;CAErB,sDAA8B;EAC5B;EACA;EACA,mBAAmB;EACpB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACEJ,MAAa,kBAIX,OACA,UAAiC,EAAE,KACP;CAK5B,IAAIC,iCAAS,OAAO,EAAE,YAJHC,mCAAW,SAAS,aAAa,GAChD,QAAQ,aACR,QAE8B,CAAC,EAAE;CAErC,sDAA8B;EAC5B;EACA;EACA,mBAAmB;EACpB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["isBigInt","isNumber","hasOwnProp"],"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,IAAIA,0BAAS,KAAK,GAAG;CAErB,sDAA8B;EAC5B;EACA;EACA,mBAAmB;CACrB,CAAC;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACCA,MAAa,kBAIX,OACA,UAAiC,CAAC,MACN;CAK5B,IAAIC,iCAAS,OAAO,EAAE,YAJHC,mCAAW,SAAS,YAAY,IAC/C,QAAQ,aACR,OAE6B,CAAC,GAAG;CAErC,sDAA8B;EAC5B;EACA;EACA,mBAAmB;CACrB,CAAC;AACH"}
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
* ========================================================================
|
|
3
3
|
* @rzl-zone/utils-js
|
|
4
4
|
* ------------------------------------------------------------------------
|
|
5
|
-
* Version: `3.13.
|
|
5
|
+
* Version: `3.13.1-beta.0`
|
|
6
6
|
* Author: `Rizalvin Dwiky <rizalvindwiky@gmail.com>`
|
|
7
7
|
* Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/utils-js`
|
|
8
8
|
* ========================================================================
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import { a as 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-CJx0EFQ4.cjs";
|
|
12
12
|
export { assertIsArray, assertIsBigInt, assertIsBoolean, assertIsNumber, assertIsPlainObject, assertIsString };
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
* ========================================================================
|
|
3
3
|
* @rzl-zone/utils-js
|
|
4
4
|
* ------------------------------------------------------------------------
|
|
5
|
-
* Version: `3.13.
|
|
5
|
+
* Version: `3.13.1-beta.0`
|
|
6
6
|
* Author: `Rizalvin Dwiky <rizalvindwiky@gmail.com>`
|
|
7
7
|
* Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/utils-js`
|
|
8
8
|
* ========================================================================
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import { a as 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-hOCUw-B9.js";
|
|
12
12
|
export { assertIsArray, assertIsBigInt, assertIsBoolean, assertIsNumber, assertIsPlainObject, assertIsString };
|
package/dist/assertions/index.js
CHANGED
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
* ========================================================================
|
|
3
3
|
* @rzl-zone/utils-js
|
|
4
4
|
* ------------------------------------------------------------------------
|
|
5
|
-
* Version: `3.13.
|
|
5
|
+
* Version: `3.13.1-beta.0`
|
|
6
6
|
* Author: `Rizalvin Dwiky <rizalvindwiky@gmail.com>`
|
|
7
7
|
* Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/utils-js`
|
|
8
8
|
* ========================================================================
|
|
9
9
|
*/
|
|
10
|
-
import { T as assertIsPlainObject, b as hasOwnProp, n as resolveErrorMessageAssertions, t as assertIsBoolean, w as isNumber } from "../assertIsBoolean-
|
|
11
|
-
import { t as isBigInt } from "../isBigInt-
|
|
12
|
-
import { t as assertIsArray } from "../assertIsArray-
|
|
13
|
-
import { t as assertIsString } from "../assertIsString-
|
|
10
|
+
import { T as assertIsPlainObject, b as hasOwnProp, n as resolveErrorMessageAssertions, t as assertIsBoolean, w as isNumber } from "../assertIsBoolean-DDhQ2D-k.js";
|
|
11
|
+
import { t as isBigInt } from "../isBigInt-f6yY2fAV.js";
|
|
12
|
+
import { t as assertIsArray } from "../assertIsArray-DrLORH0Y.js";
|
|
13
|
+
import { t as assertIsString } from "../assertIsString-1iLqxrN0.js";
|
|
14
14
|
const assertIsBigInt = (value, options = {}) => {
|
|
15
15
|
if (isBigInt(value)) return;
|
|
16
16
|
resolveErrorMessageAssertions({
|
|
@@ -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,EAAE,KACD;CAC5B,IAAI,SAAS,MAAM,EAAE;CAErB,8BAA8B;EAC5B;EACA;EACA,mBAAmB;EACpB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACEJ,MAAa,kBAIX,OACA,UAAiC,EAAE,KACP;CAK5B,IAAI,SAAS,OAAO,EAAE,YAJH,WAAW,SAAS,aAAa,GAChD,QAAQ,aACR,QAE8B,CAAC,EAAE;CAErC,8BAA8B;EAC5B;EACA;EACA,mBAAmB;EACpB,CAAC"}
|
|
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"}
|
|
@@ -2,18 +2,18 @@
|
|
|
2
2
|
* ========================================================================
|
|
3
3
|
* @rzl-zone/utils-js
|
|
4
4
|
* ------------------------------------------------------------------------
|
|
5
|
-
* Version: `3.13.
|
|
5
|
+
* Version: `3.13.1-beta.0`
|
|
6
6
|
* Author: `Rizalvin Dwiky <rizalvindwiky@gmail.com>`
|
|
7
7
|
* Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/utils-js`
|
|
8
8
|
* ========================================================================
|
|
9
9
|
*/
|
|
10
10
|
"use strict";
|
|
11
11
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
12
|
-
const require_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-D-jHROts.cjs');
|
|
13
|
+
const require_conversions = require('../conversions-Bxa01uIl.cjs');
|
|
14
|
+
const require_safeStableStringify = require('../safeStableStringify-4b-E_UHM.cjs');
|
|
15
|
+
const require_parsing = require('../parsing-CuezVd0e.cjs');
|
|
16
|
+
const require_safeJsonParse = require('../safeJsonParse-BznDD3fi.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.13.
|
|
5
|
+
* Version: `3.13.1-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 { _ 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-BAeeggeh.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.13.
|
|
5
|
+
* Version: `3.13.1-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 { _ 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-BAeeggeh.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.13.
|
|
5
|
+
* Version: `3.13.1-beta.0`
|
|
6
6
|
* Author: `Rizalvin Dwiky <rizalvindwiky@gmail.com>`
|
|
7
7
|
* Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/utils-js`
|
|
8
8
|
* ========================================================================
|
|
9
9
|
*/
|
|
10
|
-
import { 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-NreW1dyV.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-CA_3PTAH.js";
|
|
12
|
+
import { t as safeStableStringify } from "../safeStableStringify-BLwA1VC-.js";
|
|
13
|
+
import { t as parseCurrencyString } from "../parsing-BYo6U0EG.js";
|
|
14
|
+
import { i as parseCustomDate, n as extractDigits, r as cleanParsedData, t as safeJsonParse } from "../safeJsonParse-D8H3wCv7.js";
|
|
15
15
|
export { cleanParsedData, convertType, dedupeArray, extractDigits, filterNilArray, parseCurrencyString, parseCustomDate, removeObjectPaths, safeJsonParse, safeStableStringify, toBooleanContent, toBooleanContentDeep, toBooleanExplicit, toBooleanLoose, toNumberArrayUnRecursive, toNumberDeep, toStringArrayUnRecursive, toStringDeep, toStringDeepForce };
|
|
@@ -2,22 +2,22 @@
|
|
|
2
2
|
* ========================================================================
|
|
3
3
|
* @rzl-zone/utils-js
|
|
4
4
|
* ------------------------------------------------------------------------
|
|
5
|
-
* Version: `3.13.
|
|
5
|
+
* Version: `3.13.1-beta.0`
|
|
6
6
|
* Author: `Rizalvin Dwiky <rizalvindwiky@gmail.com>`
|
|
7
7
|
* Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/utils-js`
|
|
8
8
|
* ========================================================================
|
|
9
9
|
*/
|
|
10
10
|
"use strict";
|
|
11
|
-
const require_assertIsBoolean = require('./assertIsBoolean-
|
|
12
|
-
const require_isBigInt = require('./isBigInt-
|
|
13
|
-
const require_assertIsArray = require('./assertIsArray-
|
|
14
|
-
const require_assertIsString = require('./assertIsString-
|
|
15
|
-
const require_isEmptyObject = require('./isEmptyObject-
|
|
16
|
-
const require_toStringArrayUnRecursive = require('./toStringArrayUnRecursive-
|
|
17
|
-
const require_safeStableStringify = require('./safeStableStringify-
|
|
18
|
-
const require_isEqual = require('./isEqual-
|
|
19
|
-
const require_isEmptyString = require('./isEmptyString-
|
|
20
|
-
const require_isTypedArray = require('./isTypedArray-
|
|
11
|
+
const require_assertIsBoolean = require('./assertIsBoolean-CEx4KbHg.cjs');
|
|
12
|
+
const require_isBigInt = require('./isBigInt-CqZNWVtI.cjs');
|
|
13
|
+
const require_assertIsArray = require('./assertIsArray-CqIFmlgj.cjs');
|
|
14
|
+
const require_assertIsString = require('./assertIsString-DGDLC-XD.cjs');
|
|
15
|
+
const require_isEmptyObject = require('./isEmptyObject-C2lQyFZS.cjs');
|
|
16
|
+
const require_toStringArrayUnRecursive = require('./toStringArrayUnRecursive-D-jHROts.cjs');
|
|
17
|
+
const require_safeStableStringify = require('./safeStableStringify-4b-E_UHM.cjs');
|
|
18
|
+
const require_isEqual = require('./isEqual-D8W3Wizi.cjs');
|
|
19
|
+
const require_isEmptyString = require('./isEmptyString-DNMPmS-H.cjs');
|
|
20
|
+
const require_isTypedArray = require('./isTypedArray-CWlHRz_O.cjs');
|
|
21
21
|
function toNumberArrayUnRecursive(array, options = {}) {
|
|
22
22
|
require_assertIsBoolean.assertIsPlainObject(options, { message: ({ currentType, validType }) => `Second parameter (\`options\`) must be of type \`${validType}\`, but received: \`${currentType}\`.` });
|
|
23
23
|
const riv = require_assertIsBoolean.hasOwnProp(options, "removeInvalidValueNumber") ? options.removeInvalidValueNumber : true;
|
|
@@ -443,4 +443,4 @@ Object.defineProperty(exports, 'toStringDeepForce', {
|
|
|
443
443
|
return toStringDeepForce;
|
|
444
444
|
}
|
|
445
445
|
});
|
|
446
|
-
//# sourceMappingURL=conversions-
|
|
446
|
+
//# sourceMappingURL=conversions-Bxa01uIl.cjs.map
|