{"version":3,"file":"index.cjs","names":["isBigInt","isNumber"],"sources":["../../src/assertions/number/assertIsBigInt.ts","../../src/assertions/number/assertIsNumber.ts"],"sourcesContent":["import { isBigInt } from \"@/predicates/is/isBigInt\";\n\nimport {\n  resolveErrorMessageAssertions,\n  type OptionsAssertIs\n} from \"../_private/assertIs\";\n\n/** --------------------------------------------------------------------------------\n * * ***Type guard assertion: `assertIsBigInt`.***\n * ---------------------------------------------------------------------------------\n * **This function is an **assertion function**.**\n *\n * - **Behavior:**\n *     - Validates that the given `value` is a **bigint**.\n *     - After it returns successfully, TypeScript narrows the type of `value` to `bigint`.\n *     - If `value` is a `bigint` ➔ execution continues normally.\n *     - If `value` is not a `bigint` ➔ throws a built-in error with either:\n *       - A custom error message (`options.message`), or\n *       - A default message including the actual type.\n * - **Note:**\n *     - A `bigint` refers strictly to the JavaScript `bigint` primitive type (e.g., `123n`, `0n`, `-999999999999999999999n`).\n *     - This excludes `BigInt` objects created with `Object(BigInt(123))`.\n * - **Error type selection (`options.errorType`):**\n *     - You can override the type of error thrown when validation fails.\n *     - Must be one of the standard JavaScript built-in errors:\n *       - [`TypeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError) |\n *         [`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) |\n *         [`EvalError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/EvalError) |\n *         [`RangeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RangeError) |\n *         [`ReferenceError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ReferenceError) |\n *         [`SyntaxError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SyntaxError) |\n *         [`URIError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/URIError).\n *     - **Default:** `\"TypeError\"` if not provided or invalid.\n *\n * @param {*} value - ***The value to validate.***\n * @param {OptionsAssertIs} [options]\n *  ***Optional configuration:***\n *     - `message`: A custom error message (`string` or `function`).\n *     - `errorType`: Built-in JavaScript error type to throw on failure (default `\"TypeError\"`).\n *     - `formatCase`: Controls how detected type names are formatted case in error messages.\n *     - `useAcronyms`: Control uppercase preservation of recognized acronyms during formatting.\n *\n * @throws [`TypeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError) | [`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) | [`EvalError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/EvalError) | [`RangeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RangeError) | [`ReferenceError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ReferenceError) | [`SyntaxError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SyntaxError) | [`URIError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/URIError) if the value is not a bigint.\n * @returns {boolean} Narrows `value` to `bigint` if no error is thrown.\n *\n * @example\n * ```ts\n * // ✅ Simple usage\n * assertIsBigInt(123n);\n * // No error, value is bigint\n *\n * // ❌ Throws TypeError (default behavior)\n * assertIsBigInt(42);\n * // ➔ TypeError: \"Parameter input (`value`) must be of type `bigint`, but received: `number`.\"\n *\n * // ❌ Throws a TypeError with a custom string static message\n * assertIsBigInt(\"123\", { message: \"Must be a bigint!\" });\n * // ➔ TypeError: \"Must be a bigint!\"\n *\n * // ❌ Throws custom error type (e.g., RangeError)\n * assertIsBigInt(async function () {}, { errorType: \"RangeError\" });\n * // ➔ RangeError: \"Parameter input (`value`) must be of type `bigint`, but received: `async-function`.\"\n *\n * // ❌ Throws a TypeError with a custom message function and formatCase\n * assertIsBigInt(/regex/, {\n *   message: ({ currentType, validType }) => {\n *     return `Expected ${validType} but got (${currentType}).`\n *   },\n *   formatCase: \"toPascalCaseSpace\"\n * });\n * // ➔ TypeError: \"Expected bigint but got (Reg Exp).\"\n *\n * // ❌ Throws a TypeError with a custom useAcronyms option\n * // Case 1:\n * assertIsBigInt(new URL(\"https://example.com\"),{\n *   message: ({ currentType, validType }) => {\n *     return `Expected ${validType} but got (${currentType}).`\n *   },\n * });\n * // ➔ TypeError: \"Expected bigint but got (url).\"\n * assertIsBigInt(new URL(\"https://example.com\"), {\n *   useAcronyms: true,\n *   message: ({ currentType, validType }) => {\n *     return `Expected ${validType} but got (${currentType}).`\n *   },\n * });\n * // ➔ TypeError: \"Expected bigint but got (URL).\"\n *\n * // Case 2:\n * assertIsBigInt(new URLSearchParams, {\n *   formatCase: \"toPascalCase\",\n *   message: ({ currentType, validType }) => {\n *     return `Expected ${validType} but got (${currentType}).`\n *   },\n * });\n * // ➔ TypeError: \"Expected bigint but got (UrlSearchParams).\"\n * assertIsBigInt(new URLSearchParams, {\n *   useAcronyms: true,\n *   formatCase: \"toPascalCase\",\n *   message: ({ currentType, validType }) => {\n *     return `Expected ${validType} but got (${currentType}).`\n *   },\n * });\n * // ➔ TypeError: \"Expected bigint but got (URLSearchParams).\"\n * ```\n * -------------------------------------------------------\n * ✅ ***Real-world usage example***:\n * ```ts\n * const mixedValue: string | bigint | undefined = getUserInput();\n *\n * // Runtime assertion: throws if `mixedValue` is not a `bigint`\n * assertIsBigInt(mixedValue, {\n *   errorType: \"RangeError\",\n *   message: \"Must be bigint!\"\n * });\n *\n * // ✅ If no error thrown, TypeScript narrows `mixedValue` to `bigint` here\n * const result: bigint = mixedValue; // ➔ Safe type assignment\n * console.log(result + 100n);        // ➔ Safe to operation\n * ```\n */\nexport const assertIsBigInt: (\n  value: unknown,\n  options?: OptionsAssertIs\n) => asserts value is bigint = (\n  value: unknown,\n  options?: OptionsAssertIs\n): asserts value is bigint => {\n  if (isBigInt(value)) return;\n\n  resolveErrorMessageAssertions({\n    value,\n    options,\n    requiredValidType: \"bigint\"\n  });\n};\n","import { isNumber, type IsNumberOptions } from \"@/predicates/is/isNumber\";\n\nimport {\n  resolveErrorMessageAssertions,\n  type OptionsAssertIs\n} from \"../_private/assertIs\";\n\ntype OptionsAssertIsNumber = OptionsAssertIs & IsNumberOptions;\n\n/** --------------------------------------------------------------------------------\n * * ***Type guard assertion: `assertIsNumber`.***\n * ---------------------------------------------------------------------------------\n * **This function is an **assertion function**.**\n *\n * - **Behavior:**\n *     - Validates that the given `value` is a **number**.\n *     - After it returns successfully, TypeScript narrows the type of `value` to `number`.\n *     - If `value` is a `number` ➔ execution continues normally.\n *     - If `value` is not a `number` ➔ throws a built-in error with either:\n *       - A custom error message (`options.message`), or\n *       - A default message including the actual type.\n * - **Note:**\n *     - A `number` refers strictly to the JavaScript `number` primitive type (e.g., `42`, `3.14`, `-1`, `0`).\n *     - This excludes `Number` objects created with `new Number(123)`.\n *     - By default, `NaN` is **not considered** valid, you can allow it with `{ includeNaN: true }`.\n * - **Error type selection (`options.errorType`):**\n *     - You can override the type of error thrown when validation fails.\n *     - Must be one of the standard JavaScript built-in errors:\n *       - [`TypeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError) |\n *         [`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) |\n *         [`EvalError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/EvalError) |\n *         [`RangeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RangeError) |\n *         [`ReferenceError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ReferenceError) |\n *         [`SyntaxError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SyntaxError) |\n *         [`URIError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/URIError).\n *     - **Default:** `\"TypeError\"` if not provided or invalid.\n *\n * @param {*} value - ***The value to validate.***\n * @param {OptionsAssertIsNumber} [options]\n *  ***Optional configuration:***\n *     - `message`: A custom error message (`string` or `function`).\n *     - `errorType`: Built-in JavaScript error type to throw on failure (default `\"TypeError\"`).\n *     - `formatCase`: Controls how detected type names are formatted case in error messages.\n *     - `useAcronyms`: Control uppercase preservation of recognized acronyms during formatting.\n *     - `includeNaN`: Whether to treat `NaN` as valid.\n *\n * @throws [`TypeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError) | [`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) | [`EvalError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/EvalError) | [`RangeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RangeError) | [`ReferenceError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ReferenceError) | [`SyntaxError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SyntaxError) | [`URIError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/URIError) if the value is not a number (or is `NaN` when `includeNaN` is `false`).\n * @returns {boolean} Narrows `value` to `number` if no error is thrown.\n *\n * @example\n * ```ts\n * // ✅ Simple usage\n * assertIsNumber(123);\n * assertIsNumber(NaN, { includeNaN: true });\n * // No error, value is number\n *\n * // ❌ Throws TypeError (default behavior)\n * // Case 1: Invalid input type — received a string instead of a number\n * assertIsNumber(\"42\");\n * // ➔ TypeError: \"Parameter input (`value`) must be of type `number`, but received: `string`.\"\n *\n * // Case 2: Default option includeNaN is false\n * assertIsNumber(NaN);\n * // ➔ TypeError: \"Parameter input (`value`) must be of type `number`, but received: `NaN`.\"\n *\n * // Case 3: The new Number() is a Number object (constructor), not a primitive number\n * assertIsNumber(new Number(\"123\"));\n * // ➔ TypeError: \"Parameter input (`value`) must be of type `number`, but received: `number-constructor`.\"\n *\n * // ❌ Throws custom error type (e.g., RangeError)\n * assertIsNumber(async function () {}, { errorType: \"RangeError\" });\n * // ➔ RangeError: \"Parameter input (`value`) must be of type `number`, but received: `async-function`.\"\n *\n * // ❌ Throws a TypeError with a custom string static message\n * assertIsNumber(\"123\", { message: \"Must be a number!\" });\n * // ➔ TypeError: \"Must be a number!\"\n *\n * // ❌ Throws a TypeError with a custom message function and formatCase\n * assertIsNumber(/regex/, {\n *   message: ({ currentType, validType }) => {\n *     return `Expected ${validType} but got (${currentType}).`\n *   },\n *   formatCase: \"toPascalCaseSpace\"\n * });\n * // ➔ TypeError: \"Expected number but got (Reg Exp).\"\n *\n * // ❌ Throws a TypeError with a custom useAcronyms option\n * // Case 1:\n * assertIsNumber(new URL(\"https://example.com\"),{\n *   message: ({ currentType, validType }) => {\n *     return `Expected ${validType} but got (${currentType}).`\n *   },\n * });\n * // ➔ TypeError: \"Expected number but got (url).\"\n * assertIsNumber(new URL(\"https://example.com\"), {\n *   useAcronyms: true,\n *   message: ({ currentType, validType }) => {\n *     return `Expected ${validType} but got (${currentType}).`\n *   },\n * });\n * // ➔ TypeError: \"Expected number but got (URL).\"\n *\n * // Case 2:\n * assertIsNumber(new URLSearchParams, {\n *   formatCase: \"toPascalCase\",\n *   message: ({ currentType, validType }) => {\n *     return `Expected ${validType} but got (${currentType}).`\n *   },\n * });\n * // ➔ TypeError: \"Expected number but got (UrlSearchParams).\"\n * assertIsNumber(new URLSearchParams, {\n *   useAcronyms: true,\n *   formatCase: \"toPascalCase\",\n *   message: ({ currentType, validType }) => {\n *     return `Expected ${validType} but got (${currentType}).`\n *   },\n * });\n * // ➔ TypeError: \"Expected number but got (URLSearchParams).\"\n * ```\n * -------------------------------------------------------\n * ✅ ***Real-world usage example***:\n * ```ts\n * const mixedValue: string | number | undefined = getUserInput();\n *\n * // Runtime assertion: throws if `mixedValue` is not a `number`\n * assertIsNumber(mixedValue, {\n *   errorType: \"RangeError\",\n *   message: \"Must be number!\"\n * });\n *\n * // ✅ If no error thrown, TypeScript narrows `mixedValue` to `number` here\n * const result: number = mixedValue; // ➔ Safe type assignment\n * console.log(result + 100);         // ➔ Safe to operation\n * ```\n */\nexport const assertIsNumber: (\n  value: unknown,\n  options?: OptionsAssertIsNumber\n) => asserts value is number = (\n  value: unknown,\n  options?: OptionsAssertIsNumber\n): asserts value is number => {\n  const includeNaN = options?.includeNaN ?? undefined;\n\n  if (isNumber(value, { includeNaN })) return;\n\n  resolveErrorMessageAssertions({\n    value,\n    options,\n    requiredValidType: \"number\"\n  });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyHA,MAAa,kBAIX,OACA,YAC4B;CAC5B,IAAIA,0BAAS,KAAK,GAAG;CAErB,6CAA8B;EAC5B;EACA;EACA,mBAAmB;CACrB,CAAC;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACAA,MAAa,kBAIX,OACA,YAC4B;CAG5B,IAAIC,0BAAS,OAAO,EAAE,YAFH,SAAS,cAAc,OAET,CAAC,GAAG;CAErC,6CAA8B;EAC5B;EACA;EACA,mBAAmB;CACrB,CAAC;AACH"}
