{"version":3,"sources":["../src/arr/formatStrToFuncArgs.ts","../src/arr/splitArrToPortions.ts","../src/bool/formatToBool.ts","../src/common/wait.ts","../src/date/floorDateToMinutes.ts","../src/date/formatDateToString.ts","../src/date/partsToSeconds.ts","../src/date/secondsToParts.ts","../src/ip-addr/cidrToRange.ts","../src/ip-addr/ipAddrToNum.ts","../src/ip-addr/numToIpAddr.ts","../src/ip-addr/parseIPv4.ts","../src/ip-addr/rangeIPv4.ts","../src/ip-addr/rangeIPv4ToArr.ts","../src/ip-addr/toIPv4.ts","../src/is/isArr.ts","../src/is/isArrFilled.ts","../src/is/isBool.ts","../src/is/isDate.ts","../src/is/isEmail.ts","../src/is/isExists.ts","../src/is/isFunc.ts","../src/is/isIpAddr.ts","../src/is/isMacAddr.ts","../src/is/isNum.ts","../src/is/isNumFloat.ts","../src/is/isNumN.ts","../src/is/isNumNZ.ts","../src/is/isNumP.ts","../src/is/isNumPZ.ts","../src/is/isObj.ts","../src/is/isObjFilled.ts","../src/is/isPassword.ts","../src/is/isPhone.ts","../src/is/isStr.ts","../src/is/isStrBool.ts","../src/is/isStrFilled.ts","../src/is/isStrAscDesc.ts","../src/is/isVar.ts","../src/json/parseStringLike.ts","../src/json/tryParseJSON.ts","../src/json/jsonDecode.ts","../src/json/jsonEncode.ts","../src/num/changeFixedDecimalScale.ts","../src/num/convertExponentialToParts.ts","../src/num/fixedDecimalToNum.ts","../src/num/fixedDecimalToStr.ts","../src/num/formatToNum.ts","../src/num/normalizeToDecimalComponents.ts","../src/num/parseToFixedDecimal.ts","../src/num/roundFixedDecimal.ts","../src/str/formatToLowerCase.ts","../src/str/formatToNormalCase.ts","../src/str/formatToNull.ts","../src/str/formatToPhone.ts","../src/str/formatToTrim.ts","../src/str/formatToUndefined.ts","../src/units/toGB.ts","../src/units/normalizeUnit.ts","../src/units/toGH.ts","../src/units/toH.ts","../src/url/extractHost.ts"],"names":["formatStrToFuncArgs","value","isStr","src","buf","inQuote","quoteChar","esc","depthParen","depthBracket","depthBrace","items","finalize","trimmed","i","ch","raw","isStrBool","formatToBool","n","formatToNum","rawStr","jsonDecode","splitArrToPortions","arr","portionLength","out","isBool","isNumP","isNumNZ","isStrFilled","wait","timeout","resolve","floorDateToMinutes","everyMinutes","date","step","m","floored","d","formatDateToString","pad","year","month","day","hours","minutes","seconds","partsToSeconds","parts","days","secondsToParts","total","cidrToRange","cidr","ip","maskStr","base","parseIPv4","mask","netmask","start","end","toIPv4","ipAddrToNum","p","buffer","dv","numToIpAddr","num","nbuffer","ndv","output","formatToTrim","rangeIPv4","from","to","opts","includeNetwork","includeBroadcast","startNum","endNum","isCIDR","cidrMask","range","startStr","endStr","_","s","e","a","b","c","skipNetworkAt","skipBroadcastAt","cur","rangeIPv4ToArr","limit","count","isArr","isArrFilled","isDate","isNum","emailRegex","isEmail","isExists","isFunc","IPV4_RE","isIpAddr","v","isMacAddr","isNumFloat","isNumN","isNumPZ","isObj","isObjFilled","isPassword","minLength","maxLength","requireUppercase","requireLowercase","requireDigit","requireSpecial","isPhone","valueProcessed","normalized","isStrAscDesc","isVar","QUOTED_RE","parseStringLike","allowString","pr","tryParseJSON","str","item","key","jsonEncode","changeFixedDecimalScale","scaleDelta","delta","multiplier","convertExponentialToParts","sign","exponentialString","match","coefficient","exponentText","integerPart","fractionalPart","allDigits","exponentValue","exponent","digitsToLeft","missingZeros","splitIndex","fixedDecimalToNum","fixedDecimalToStr","signSymbol","allDigitsString","padZeros","integerBoundary","integerText","fractionalText","round","throwError","roundFixedDecimal","parseToFixedDecimal","err","normalizeToDecimalComponents","input","absoluteValue","exponentialForm","processed","integerDigits","fractionalDigits","combinedDigits","source","decimalPlaces","roundMode","targetPrecision","digitsToRemove","divisionFactor","remainder","halfThreshold","roundedValue","formatToLowerCase","formatToNormalCase","parsed","formatToNull","formatToPhone","defaultCountry","phone","formatToUndefined","KB","MB","GB","TB","PB","toGB","unit","u","normalizeUnit","FACTOR","toGH","factor","FACTOR_H","toH","HAS_SCHEME","extractHost","candidate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MC,CAAAA,CAAAA,CADerG,EAAE,KAAA,CAAM,GAAG,EAAE,GAAA,EAAI,EAAKA,GACT,KAAA,CAAM,OAAA,CAAS,CAAC,CAAA,CAAE,CAAC,EAC/CsG,CAAAA,CAAQD,CAAAA,CAAa,MAAM,eAAe,CAAA,CAEhD,OAAIC,CAAAA,CACIA,CAAAA,CAAM,CAAC,CAAA,CAERD,CAAAA,CAAa,MAAM,GAAA,CAAK,CAAC,EAAE,CAAC,CAAA,EAAK,EACzC,CACD","file":"index.mjs","sourcesContent":["import { \n\tisStrBool,\n\tisStr, \n\tjsonDecode,\n\tformatToBool,\n\tformatToNum,\n} from '../index';\n\n/**\n * A narrow union describing which quoting characters are recognized by the parser.\n *\n * @remarks\n * The parser treats both single quotes (`'`) and double quotes (`\"`) as valid string\n * delimiters. When inside a quoted segment, commas are not considered separators,\n * and typical backslash escapes are honored (e.g., `\\\"`, `\\'`, `\\\\`).\n *\n * @public\n * @since 2.0.0\n */\ntype Quote = \"'\" | '\"' | null;\n\n/**\n * Parse a human-typed string of function-like arguments into a normalized array of JS values.\n *\n * @summary\n * Splits by **top-level commas** (ignoring commas that appear inside quotes, parentheses,\n * brackets, or braces) and **coerces** each token to a sensible JavaScript type:\n * `null`, `undefined`, booleans, numbers (including `Infinity`/`-Infinity`), strings\n * (with quote stripping and unescaping), and JSON objects/arrays. Tokens that look like\n * a macro or call marker (start with `$` and end with `)`) are returned **as is**.\n *\n * @remarks\n * ### How parsing works\n * 1. **Input normalization**\n *    - Non-string inputs are returned as a single-element array `[value]`.\n *    - Leading/trailing whitespace is trimmed.\n *    - If the entire string is wrapped in square brackets (`[...]`), the brackets are\n *      removed (so the function accepts both `a,b,c` and `[a, b, c]`).\n *    - Empty input (after trimming or after removing `[...]`) yields `[]`.\n *\n * 2. **Tokenization by top-level commas**\n *    - The string is scanned left-to-right.\n *    - The parser tracks nesting **depth** for `()`, `[]`, `{}` and whether it is\n *      currently **inside quotes**. A comma only splits tokens at **depth 0** and\n *      **outside quotes**.\n *\n * 3. **Per-token coercion (in this order)**\n *    - **Macro / call marker**: If a token starts with `$`, contains `(`, and ends\n *      with `)`, it is returned unchanged (e.g., `\"$env(PATH)\"`).\n *    - **Literals**: `null` → `null`, `undefined` → `undefined`.\n *    - **Booleans**: Using {@link isStrBool} + {@link formatToBool} (e.g., `\"true\"`,\n *      `\"False\"`, `\"yes\"`, `\"0\"` depending on your implementation).\n *    - **Numbers**: Using {@link formatToNum}. If the result is finite, it is returned.\n *      Explicit `\"Infinity\"` and `\"-Infinity\"` are also supported.\n *    - **Quoted strings**: `'text'` or `\"text\"` → inner text with escapes processed\n *      (`\\\\` → `\\`, `\\'` → `'`, `\\\"` → `\"`).\n *    - **JSON**: If token begins with `{` and ends with `}`, or begins with `[` and\n *      ends with `]`, the function attempts `jsonDecode`. On failure, the raw string\n *      is returned.\n *    - **Fallback**: Raw token as string.\n *\n * ### Escaping inside quotes\n * - Backslash escaping is supported while inside quotes:\n *   - `\\\\` for a literal backslash\n *   - `\\\"` inside double quotes\n *   - `\\'` inside single quotes\n *\n * ### Non-throwing behavior\n * - The function aims to be **robust** and **non-throwing**. Invalid JSON will be\n *   returned as a plain string rather than crashing.\n *\n * ### Security considerations\n * - The parser **does not** evaluate code; it only returns strings or parsed values.\n *   If you plan to execute anything returned (e.g., tokens starting with `$...`),\n *   do so in a sandbox with explicit allow-lists.\n *\n * ### Limitations\n * - Numerical parsing relies on {@link formatToNum}. Extremely large or high-precision\n *   decimals may still be subject to JavaScript `number` precision limits unless your\n *   `formatToNum` converts to a safer representation.\n * - Only basic backslash escapes are handled in quoted strings (no `\\uXXXX` decoding here).\n * - Whitespace outside quotes is trimmed from each token; internal whitespace is preserved.\n *\n * @example\n * // Basic values\n * formatStrToFuncArgs('1, true, \"hello\"'); // => [1, true, \"hello\"]\n *\n * @example\n * // Bracket-wrapped list\n * formatStrToFuncArgs('[1, 2, 3]'); // => [1, 2, 3]\n *\n * @example\n * // Nested structures and quoting\n * formatStrToFuncArgs('{\"a\":1,\"b\":[2,3]}, \"te,xt\", (x,y)'); // => [ {a:1,b:[2,3]}, \"te,xt\", \"(x,y)\" ]\n *\n * @example\n * // Booleans, null/undefined, and Infinity\n * formatStrToFuncArgs('yes, NO, null, undefined, Infinity, -Infinity');\n * // => [true, false, null, undefined, Infinity, -Infinity]\n *\n * @example\n * // Macro-like token (returned as-is)\n * formatStrToFuncArgs('$env(PATH)'); // => [\"$env(PATH)\"]\n *\n * @example\n * // Escapes inside quotes\n * formatStrToFuncArgs('\"He said: \\\\\"Hi\\\\\"\", \\'It\\\\\\'s ok\\', \"\\\\\\\\path\"');\n * // => ['He said: \"Hi\"', \"It's ok\", \"\\\\path\"]\n *\n * @example\n * // Empty and whitespace inputs\n * formatStrToFuncArgs('   ');          // => []\n * formatStrToFuncArgs('[]');           // => []\n * formatStrToFuncArgs('[   ]');        // => []\n * formatStrToFuncArgs('  [ a , b ] '); // => [\"a\", \"b\"]\n *\n * @param value - Raw string containing comma-separated arguments.\n * If `value` is **not** a string, the function returns `[value]` unchanged.\n *\n * @returns An array of coerced values (`unknown[]`). Each item is one parsed token.\n *\n * @see isStrBool\n * @see formatToBool\n * @see formatToNum\n * @see jsonDecode\n *\n * @public\n * @since 2.0.0\n */\nexport function formatStrToFuncArgs(value: string): unknown[] {\n\tif (!isStr(value)) {\n\t\treturn [value];\n\t}\n\tlet src = value.trim();\n\t\n\tif (src === '') {\n\t\treturn [];\n\t}\n\tif (src.startsWith('[') && src.endsWith(']')) {\n\t\tsrc = src.slice(1, -1).trim();\n\t\t\n\t\tif (src === '') {\n\t\t\treturn [];\n\t\t}\n\t}\n\tlet buf = '',\n\t\tinQuote = false,\n\t\tquoteChar: Quote = null,\n\t\tesc = false,\n\t\tdepthParen = 0,\n\t\tdepthBracket = 0,\n\t\tdepthBrace = 0;\n\n\tconst items: string[] = [];\n\tconst finalize = () => {\n\t\tconst trimmed = buf.trim();\n\t\t\n\t\tif (trimmed !== '') {\n\t\t\titems.push(trimmed);\n\t\t}\n\t\tbuf = '';\n\t};\n\n\tfor (let i = 0; i < src.length; i++) {\n\t\tconst ch = src[i];\n\n\t\tif (inQuote) {\n\t\t\tbuf += ch;\n\n\t\t\tif (esc) { \n\t\t\t\tesc = false; \n\t\t\t\tcontinue; \n\t\t\t}\n\t\t\tif (ch === '\\\\') { \n\t\t\t\tesc = true; \n\t\t\t\tcontinue; \n\t\t\t}\n\t\t\tif (ch === quoteChar) {\n\t\t\t\tinQuote = false;\n\t\t\t\tquoteChar = null;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\t\tif (ch === '\"' || ch === \"'\") {\n\t\t\tinQuote = true;\n\t\t\tquoteChar = ch as Quote;\n\t\t\tbuf += ch;\n\t\t\t\n\t\t\tcontinue;\n\t\t}\n\t\tif (ch === '(') { \n\t\t\tdepthParen++; \n\t\t\tbuf += ch; \n\n\t\t\tcontinue; \n\t\t}\n\t\tif (ch === ')') { \n\t\t\tdepthParen = Math.max(0, depthParen - 1); \n\t\t\tbuf += ch; \n\t\t\t\n\t\t\tcontinue; \n\t\t}\n\t\tif (ch === '[') { \n\t\t\tdepthBracket++; \n\t\t\tbuf += ch; \n\t\t\t\n\t\t\tcontinue; \n\t\t}\n\t\tif (ch === ']') { \n\t\t\tdepthBracket = Math.max(0, depthBracket - 1); \n\t\t\tbuf += ch; \n\t\t\t\n\t\t\tcontinue; \n\t\t}\n\t\tif (ch === '{') { \n\t\t\tdepthBrace++; \n\t\t\tbuf += ch; \n\t\t\t\n\t\t\tcontinue; \n\t\t}\n\t\tif (ch === '}') { \n\t\t\tdepthBrace = Math.max(0, depthBrace - 1); \n\t\t\tbuf += ch; \n\n\t\t\tcontinue; \n\t\t}\n\t\tif (ch === ',' && depthParen === 0 && depthBracket === 0 && depthBrace === 0) {\n\t\t\tfinalize();\n\t\t\t\n\t\t\tcontinue;\n\t\t}\n\t\tbuf += ch;\n\t}\n\tif (buf.length) {\n\t\tfinalize();\n\t}\n\treturn items.map((raw: string): unknown => {\n\t\tif (raw.startsWith('$') && raw.includes('(') && raw.endsWith(')')) {\n\t\t\treturn raw;\n\t\t}\n\t\tif (raw === 'null') {\n\t\t\treturn null;\n\t\t}\n\t\tif (raw === 'undefined') {\n\t\t\treturn undefined;\n\t\t}\n\t\tif (isStrBool(raw)) {\n\t\t\treturn formatToBool(raw);\n\t\t}\n\t\tconst n = formatToNum(raw as any);\n\t\t\n\t\tif (Number.isFinite(n)) {\n\t\t\treturn n;\n\t\t}\t\t\n\t\tif (raw === 'Infinity') {\n\t\t\treturn Infinity;\n\t\t}\n\t\tif (raw === '-Infinity') {\n\t\t\treturn -Infinity;\n\t\t}\n\t\tconst rawStr: string = String(raw || '');\n\t\tconst hasQuotes = rawStr.length >= 2\n\t\t\t&& ((rawStr.startsWith(\"'\") && rawStr.endsWith(\"'\")) \n\t\t\t\t|| (rawStr.startsWith('\"') && rawStr.endsWith('\"')));\n\n\t\tif (hasQuotes) {\n\t\t\treturn rawStr\n\t\t\t\t.slice(1, -1)\n\t\t\t\t.replace(/\\\\\\\\/g, '\\\\')\n\t\t\t\t.replace(/\\\\'/g, \"'\")\n\t\t\t\t.replace(/\\\\\"/g, '\"');\n\t\t}\n\t\tif ((rawStr.startsWith('{') && rawStr.endsWith('}')) || (rawStr.startsWith('[') && rawStr.endsWith(']'))) {\n\t\t\ttry {\n\t\t\t\treturn jsonDecode(rawStr);\n\t\t\t} \n\t\t\tcatch {\n\t\t\t}\n\t\t}\n\t\treturn rawStr;\n\t});\n}\n","\n/**\n * Splits an input array into smaller subarrays (portions) of a given fixed size.\n *\n * @summary\n * Returns an array of chunks, where each chunk contains at most `portionLength` elements.\n * The final chunk may contain fewer elements if the input array length is not evenly divisible\n * by `portionLength`.\n *\n * @typeParam T - Type of the elements in the input array.\n *\n * @param arr - The source array to be split. It can be any readonly array (or tuple).\n * @param portionLength - The desired size of each portion. Must be a **positive integer**.\n *\n * @returns A new two-dimensional array (`T[][]`), where each inner array is one portion.\n * If `portionLength` is not a positive integer, an empty array is returned.\n *\n * @remarks\n * - This function is **non-mutating**: the original array is never modified.\n * - If `portionLength` exceeds the array length, the result will be a single chunk\n *   containing the entire array.\n * - If the input array is empty, the result is an empty array.\n * - Uses `Array.prototype.slice()` internally, so the returned chunks are **shallow copies**.\n *\n * ### Performance\n * - Time complexity: **O(n)** — each element is visited exactly once.\n * - Space complexity: **O(n)** — proportional to the total number of elements copied.\n * - For extremely large arrays (millions of elements), prefer a streaming approach\n *   if memory is a concern.\n *\n * ### Edge cases\n * - `portionLength <= 0` → returns `[]`.\n * - `portionLength` is not an integer (e.g. `2.5`, `NaN`) → returns `[]`.\n * - `arr.length === 0` → returns `[]`.\n * - Works correctly with frozen arrays and readonly tuples.\n *\n * @example\n * // Split an array into groups of 3\n * splitArrToPortions([1, 2, 3, 4, 5, 6, 7], 3);\n * // => [[1, 2, 3], [4, 5, 6], [7]]\n *\n * @example\n * // Portion length larger than array\n * splitArrToPortions(['a', 'b'], 5);\n * // => [['a', 'b']]\n *\n * @example\n * // Non-integer or invalid sizes\n * splitArrToPortions([1, 2, 3], 0);   // => []\n * splitArrToPortions([1, 2, 3], -2);  // => []\n * splitArrToPortions([1, 2, 3], NaN); // => []\n *\n * @example\n * // Works with readonly arrays\n * const input = [10, 20, 30, 40] as const;\n * const result = splitArrToPortions(input, 2);\n * // result: [[10, 20], [30, 40]]\n *\n * @category Array\n * @public\n * @since 2.0.0\n */\nexport function splitArrToPortions<T>(arr: readonly T[], portionLength: number): T[][] {\n\tif (!Number.isInteger(portionLength) || portionLength <= 0) {\n\t\treturn [];\n\t}\n\tconst out: T[][] = [];\n\tlet i = 0;\n\t\n\twhile (i < arr.length) {\n\t\tout.push(arr.slice(i, i + portionLength));\n\t\ti += portionLength;\n\t}\n\treturn out;\n}\n","import { \n\tisBool,\n\tisNumP, \n\tisNumNZ,\n\tisStrFilled,\n} from '../index';\n\n/**\n * Converts any given value into a normalized boolean (`true` / `false`).\n *\n * @summary\n * Performs **loose coercion** of different input types into a `boolean`\n * following predictable rules for numbers, strings, and actual boolean values.\n * Non-recognized values always return `false`.\n *\n * @param value - Any unknown input that should be interpreted as a boolean.\n *\n * @returns The normalized boolean result (`true` or `false`).\n *\n * @remarks\n * This function is designed to **gracefully handle** a wide variety of input forms —\n * including primitive values, numeric types, and user-typed strings (like `\"yes\"`, `\"no\"`, `\"on\"`, `\"off\"`).\n *\n * ### Conversion Rules (in order of precedence)\n * 1. **Native booleans** → returned as-is.\n *    - `true` → `true`\n *    - `false` → `false`\n *\n * 2. **Positive numbers** → interpreted as `true`.\n *    - `isNumP(value)` check passes (typically `> 0`).\n *    - Examples: `1`, `42`, `3.14` → `true`\n *\n * 3. **Zero or negative numbers** → interpreted as `false`.\n *    - `isNumNZ(value)` check passes (typically `<= 0`).\n *    - Examples: `0`, `-1` → `false`\n *\n * 4. **Truthy strings** → `\"true\"`, `\"1\"`, `\"yes\"`, `\"on\"` (case-insensitive)\n *    - `\"TrUe\"` → `true`\n *    - `\"  YES  \"` → `true`\n *\n * 5. **Falsy strings** → `\"false\"`, `\"0\"`, `\"no\"`, `\"off\"` (case-insensitive)\n *    - `\"False\"` → `false`\n *    - `\" off \"` → `false`\n *\n * 6. **Everything else** → `false`\n *    - `null`, `undefined`, `NaN`, empty string, symbols, objects, arrays, etc.\n *\n * ### String Handling\n * - Strings are **trimmed** and **lower-cased** before comparison.\n * - Case and whitespace are ignored.\n * - Empty strings (`\"\"`) return `false`.\n *\n * ### Error Safety\n * - The function **never throws**.\n * - Non-primitive or unexpected types are handled safely and result in `false`.\n *\n * ### Performance\n * - Time complexity: **O(1)**.\n * - Space complexity: **O(1)**.\n *\n * ### Examples\n *\n * @example\n * // Native booleans\n * formatToBool(true);            // => true\n * formatToBool(false);           // => false\n *\n * @example\n * // Numeric values\n * formatToBool(1);               // => true\n * formatToBool(0);               // => false\n * formatToBool(-5);              // => false\n *\n * @example\n * // String values\n * formatToBool('yes');           // => true\n * formatToBool('No');            // => false\n * formatToBool('TRUE');          // => true\n * formatToBool('false');         // => false\n * formatToBool('on');            // => true\n * formatToBool('off');           // => false\n *\n * @example\n * // Mixed and invalid inputs\n * formatToBool(null);            // => false\n * formatToBool(undefined);       // => false\n * formatToBool([]);              // => false\n * formatToBool({});              // => false\n * formatToBool('maybe');         // => false\n *\n * @see isBool\n * @see isNumP\n * @see isNumNZ\n * @see isStrFilled\n *\n * @category Conversion\n * @public\n * @since 2.0.0\n */\nexport function formatToBool(value: unknown): boolean {\n\tswitch (true) {\n\t\tcase isBool(value):\n\t\t\treturn value;\n\n\t\tcase isNumP(value):\n\t\t\treturn true;\n\n\t\tcase isNumNZ(value):\n\t\t\treturn false;\n\n\t\tcase isStrFilled(value) && [ 'true', '1', 'yes', 'on' ].includes(String(value ?? '').trim().toLowerCase()):\n\t\t\treturn true;\n\n\t\tcase isStrFilled(value) && [ 'false', '0', 'no', 'off' ].includes(String(value ?? '').trim().toLowerCase()):\n\t\t\treturn false;\n\t}\n\treturn false;\n}\n","/**\n * Waits asynchronously for the specified amount of time.\n *\n * @summary\n * A tiny promise-based delay utility that resolves after `timeout` milliseconds.\n * It wraps `setTimeout` in a `Promise`, making it convenient to use with\n * `async/await` or as part of larger promise chains.\n *\n * @param timeout - The delay duration in **milliseconds** before the promise resolves.\n * @defaultValue 0\n *\n * @returns A `Promise<void | true>` that settles after the given delay.\n *\n * @example\n * // Basic usage: pause for ~500 ms\n * await wait(500);\n * console.log('Half a second later…');\n *\n * @example\n * // Measure elapsed time\n * const started = Date.now();\n * await wait(1200);\n * const elapsed = Date.now() - started; // ~= 1200ms (subject to timer clamping and scheduling)\n *\n * @example\n * // Use inside a retry/backoff loop\n * for (let attempt = 1; attempt <= 5; attempt++) {\n *   try {\n *     await doWork();\n *     break;\n *   } catch (err) {\n *     // exponential backoff between attempts\n *     await wait(2 ** attempt * 100);\n *   }\n * }\n *\n * @example\n * // Parallel delays (resolve when the longest finishes)\n * await Promise.all([wait(100), wait(250), wait(50)]);\n *\n * @remarks\n * - **Timing accuracy:** JavaScript timers are **best-effort** and may be delayed\n *   by event-loop load, CPU throttling, tab being backgrounded, or platform-specific\n *   clamping. Treat `timeout` as a *minimum* delay, not an exact scheduler.\n * - **Negative or non-finite values:** Passing `<= 0`, `NaN`, or a non-finite value\n *   effectively behaves like `0` and resolves on a future macrotask tick.\n * - **Cancellation:** This helper **does not support cancellation**. If you need to\n *   abort a wait, consider a variant that accepts an `AbortSignal` and clears the\n *   timer when aborted.\n * - **Event loop semantics:** `setTimeout(0)` schedules a **macrotask**; it does not\n *   run synchronously. Code after `await wait(0)` will execute on a subsequent turn\n *   of the event loop.\n * \n * Notes:\n * - Suitable for throttling UI interactions, pacing network retries, and writing\n *   deterministic tests (with caution re: flakiness).\n * - Keep delays small in performance-critical code paths; prefer debouncing or\n *   requestAnimationFrame for UI-animation pacing when appropriate.\n * \n * \tComplexity:\n * - Time: **O(1)** (scheduling a single timer)\n * - Space: **O(1)** (a promise and a timer reference)\n *\n * Performance:\n * - The function allocates a single promise and a timer handle.\n * - Timer resolution is platform dependent; Node.js and browsers may clamp very\n *   small delays to a minimum threshold under load.\n *\n * Security:\n * - No I/O, side effects, or data exposure. Purely schedules a future resolution.\n * \n * <b>Returns remarks</b>:\n * The internal promise resolves with the value `true`, but callers typically\n * use `await wait(...)` and ignore the value. If you need a strictly `void`\n * result, you can cast or ignore the resolution value.\n *\n * @category Utilities • Timing\n * @since 1.0.0\n * @see {@link https://developer.mozilla.org/docs/Web/API/setTimeout MDN: setTimeout}\n */\nexport async function wait(timeout: number = 0) {\n\tawait (new Promise((resolve) => setTimeout(() => resolve(true), timeout)));\n}\n","/**\n * Floors a given {@link Date} object down to the nearest time interval in minutes.\n *\n * @remarks\n * This utility function is commonly used for time bucketing, grouping logs, or\n * aligning timestamps to fixed intervals (e.g. 5-minute or 15-minute marks).\n *\n * It takes an arbitrary `Date` and returns a **new** `Date` instance (it does not\n * mutate the input) where:\n *\n * - The `minutes` value is floored down to the nearest multiple of `everyMinutes`.\n * - `seconds` and `milliseconds` are reset to `0`.\n * - The hour and day remain unchanged.\n *\n * The step is automatically clamped to the range **1 – 60 minutes** to prevent\n * invalid or nonsensical values.\n * \n * The function allocates a single new `Date` object.  \n * It is safe for high-frequency use in real-time systems and event batching.\n *\n * @param everyMinutes - The step interval (in minutes) used for rounding down.\n * Must be a positive finite number.  \n * Values below 1 are treated as 1, values above 60 as 60.\n *\n * @param date - The input date to be floored.  \n * Defaults to the current time (`new Date()`).\n *\n * @returns A **new** `Date` instance, representing the same hour as the input,\n * but with minutes rounded down to the nearest `everyMinutes` multiple.\n *\n * @example\n * ```ts\n * // Example 1: Floor to the nearest 15-minute mark\n * const d = new Date('2025-10-18T10:43:27');\n * floorDateToMinutes(15, d);\n * // -> 2025-10-18T10:30:00.000Z\n * ```\n *\n * @example\n * ```ts\n * // Example 2: Using default date (current time)\n * const nowFloored = floorDateToMinutes(10);\n * // -> e.g. 2025-10-18T09:20:00.000Z\n * ```\n *\n * @example\n * ```ts\n * // Example 3: Clamp behavior\n * floorDateToMinutes(-5, new Date());  // treated as 1 minute\n * floorDateToMinutes(999, new Date()); // treated as 60 minutes\n * ```\n *\n * @throws Never throws — invalid step values are automatically normalized.\n *\n * @see {@link Date#setMinutes} for the underlying mutation logic.\n * @see {@link Date#getMinutes} for how minutes are extracted from a Date.\n *\n * @public\n * @category Date & Time\n * @since 2.0.0\n */\nexport function floorDateToMinutes(everyMinutes = 1, date = new Date()): Date {\n\tconst step = Math.min(60, Math.max(1, Math.trunc(Math.abs(everyMinutes))));\n\tconst m = date.getMinutes();\n\tconst floored = Math.floor(m / step) * step;\n\tconst d = new Date(date);\n\t\n\td.setMinutes(floored, 0, 0);\n\t\n\treturn d;\n}\n","/**\n * Formats a {@link Date} object into a human-readable timestamp string\n * using the pattern `\"YYYY-MM-DD HH:mm:ss\"`.\n *\n * @remarks\n * This function is a simple and locale-independent date formatter that always\n * outputs a **24-hour clock** timestamp with leading zeros for all numeric parts.\n *  \n * It does **not** depend on the user's locale or time zone settings beyond what\n * is stored in the provided `Date` object. If you pass a `Date` constructed\n * from UTC or local time, the formatted output will reflect that same basis.\n *\n * Each date/time component (month, day, hours, minutes, seconds) is padded to\n * two digits using {@link String.padStart}, ensuring consistent width such as\n * `2025-03-07 09:04:02`.\n * \n * - The format is fixed-width and consistent — ideal for logs, filenames,\n *   and database-friendly timestamps.\n * - The output is **not ISO 8601** (which uses a `'T'` separator and optional\n *   timezone offset).  \n *   Example: ISO → `\"2025-10-18T10:43:27Z\"`  \n *   This function → `\"2025-10-18 10:43:27\"`.\n *\n * @param date - The date to format. Defaults to the **current system time**\n * (`new Date()`).\n *\n * @returns A formatted timestamp string in `\"YYYY-MM-DD HH:mm:ss\"` form.\n *\n * @example\n * ```ts\n * // Example 1: Specific date\n * const d = new Date('2025-10-18T10:43:27Z');\n * formatDateToString(d);\n * // -> \"2025-10-18 10:43:27\"\n * ```\n *\n * @example\n * ```ts\n * // Example 2: Default (current) date\n * formatDateToString();\n * // -> e.g. \"2025-10-18 12:07:55\"\n * ```\n *\n * @example\n * ```ts\n * // Example 3: Padding behavior\n * const d = new Date('2025-03-07T09:04:02');\n * formatDateToString(d);\n * // -> \"2025-03-07 09:04:02\"\n * ```\n *\n * @throws Never throws.\n *\n * @see {@link Date} for JavaScript’s native date-handling API.\n * @see {@link Intl.DateTimeFormat} for locale-aware formatting if needed.\n *\n * @public\n * @category Date & Time\n * @since 2.0.0\n */\nexport function formatDateToString(date = new Date()): string {\n\tconst pad = (n: number) => String(n).padStart(2, '0');\n\n\tconst year = date.getFullYear();\n\tconst month = pad(date.getMonth() + 1);\n\tconst day = pad(date.getDate());\n\n\tconst hours = pad(date.getHours());\n\tconst minutes = pad(date.getMinutes());\n\tconst seconds = pad(date.getSeconds());\n\n\treturn `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;\n}\n","import type { TimeParts } from '../index';\nimport { secondsToParts } from '../index';\n\n/**\n * Converts a partial {@link TimeParts} structure (days, hours, minutes, seconds)\n * into a total number of **seconds**.\n *\n * @remarks\n * This helper provides a simple way to normalize human-readable time components\n * into a single scalar duration in seconds.  \n * It can be useful for:\n * - time-based arithmetic (e.g., adding offsets to timestamps),\n * - scheduling or delay computation,\n * - serializing durations into numeric fields (e.g., databases or APIs).\n *\n * All fields (`days`, `hours`, `minutes`, `seconds`) are **optional**; any missing\n * value defaults to `0`. The calculation uses fixed conversion factors:\n *\n * - 1 day = 86 400 seconds  \n * - 1 hour = 3 600 seconds  \n * - 1 minute = 60 seconds\n * \n * - Fractional or negative numbers are accepted and processed arithmetically.\n *   Example: `{ minutes: 1.5 }` → `90`; `{ hours: -1 }` → `-3600`.\n * - The function performs no validation; it assumes numeric input.\n *   TypeScript typing (`number`) ensures intended usage.\n *\n * @param parts - A partial object containing any subset of time fields.\n * Missing values default to zero.\n *\n * @returns The total number of seconds represented by the provided time parts.\n *\n * @example\n * ```ts\n * // Example 1: Simple conversion\n * partsToSeconds({ hours: 1, minutes: 30 }); // -> 5400\n *\n * // Example 2: Full time span\n * partsToSeconds({ days: 2, hours: 3, minutes: 5, seconds: 10 });\n * // -> 183910\n *\n * // Example 3: Partial / missing fields\n * partsToSeconds({}); // -> 0\n * partsToSeconds({ minutes: 5 }); // -> 300\n * ```\n *\n * @throws Never throws.\n *\n * @see {@link secondsToParts} — the inverse operation that expands seconds back into components.\n *\n * @public\n * @category Date & Time\n * @since 2.0.0\n */\nexport function partsToSeconds(parts: {\n\tdays?: number;\n\thours?: number;\n\tminutes?: number;\n\tseconds?: number;\n}): number {\n\tconst { days = 0, hours = 0, minutes = 0, seconds = 0 } = parts;\n\n\treturn days * 86400 + hours * 3600 + minutes * 60 + seconds;\n}\n","import type { TimeParts } from '../index';\nimport { partsToSeconds } from '../index';\n\n/**\n * Decomposes a total number of seconds into discrete time components:\n * **days**, **hours**, **minutes**, and **seconds**.\n *\n * @remarks\n * This is the inverse operation of {@link partsToSeconds}.\n * It converts a flat duration (in seconds) into a more human-readable structure\n * suitable for display, logging, or formatting.\n *\n * The function performs integer division using {@link Math.floor} for each component\n * and ensures that the result satisfies:\n *\n * ```\n * 0 <= hours < 24  \n * 0 <= minutes < 60  \n * 0 <= seconds < 60\n * ```\n *\n * Any fractional part of the input (e.g., `12.75`) is truncated (floored) to the\n * nearest lower whole second.  \n * Negative or non-finite inputs are considered invalid and will throw an error.\n * \n * - Uses only a few arithmetic operations and is **O(1)**.\n * - Safe for real-time conversions or high-frequency usage (e.g., monitoring dashboards).\n *\n * @param total - Total duration in seconds.  \n * Must be a **finite, non-negative number**.\n *\n * @returns A {@link TimeParts} object with integer fields:\n * - `days`\n * - `hours`\n * - `minutes`\n * - `seconds`\n *\n * @example\n * ```ts\n * // Example 1: Basic conversion\n * secondsToParts(3661);\n * // -> { days: 0, hours: 1, minutes: 1, seconds: 1 }\n * ```\n *\n * @example\n * ```ts\n * // Example 2: Multi-day value\n * secondsToParts(90061);\n * // -> { days: 1, hours: 1, minutes: 1, seconds: 1 }\n * ```\n *\n * @example\n * ```ts\n * // Example 3: Invalid input\n * secondsToParts(-10); // throws Error(\"Invalid total seconds\")\n * secondsToParts(NaN); // throws Error(\"Invalid total seconds\")\n * ```\n *\n * @throws {Error}\n * Thrown when `total` is not a finite, non-negative number.\n *\n * @see {@link partsToSeconds} — the complementary function that aggregates components into seconds.\n * @see {@link TimeParts} — the return type describing the breakdown of time.\n *\n * @public\n * @category Date & Time\n * @since 2.0.0\n */\nexport function secondsToParts(total: number): TimeParts {\n\tif (!Number.isFinite(total) || total < 0) {\n\t\tthrow new Error('Invalid total seconds');\n\t}\n\tconst days = Math.floor(total / 86400);\n\tconst hours = Math.floor((total % 86400) / 3600);\n\tconst minutes = Math.floor((total % 3600) / 60);\n\tconst seconds = total % 60;\n\t\n\treturn { days, hours, minutes, seconds };\n}\n","import { \n\tparseIPv4,\n\ttoIPv4, \n} from '../index';\n\n/**\n * Converts a CIDR block into its inclusive start/end IPv4 addresses.\n *\n * @remarks\n * The function validates the CIDR notation and returns a tuple of dotted-quad\n * IPv4 strings representing the first and last addresses in the block.\n * For `/0` the range spans the entire IPv4 address space. For `/32` the start\n * and end are the same single address.\n *\n * @param cidr - CIDR notation string, e.g. `\"192.168.1.0/24\"` or `\"10.0.0.1/32\"`.\n * @returns A tuple `[start, end]` in dotted-quad form, or `null` if input is invalid.\n *\n * @example\n * ```ts\n * cidrToRange('192.168.1.0/24'); // ['192.168.1.0','192.168.1.255']\n * cidrToRange('10.0.0.1/32');    // ['10.0.0.1','10.0.0.1']\n * cidrToRange('bad');            // null\n * ```\n *\n * @throws Never throws; returns `null` on invalid input.\n * @see {@link parseIPv4} to parse an IPv4 string to a 32-bit number.\n * @see {@link toIPv4} to convert a number back to dotted-quad.\n * @public\n * @category IPv4\n * @since 2.0.0\n */\nexport function cidrToRange(cidr: string): [ string, string ] | null {\n\tconst [ ip, maskStr ] = cidr.split('/');\n\tconst base = parseIPv4(ip);\n\tconst mask = maskStr ? Number(maskStr) : NaN;\n\n\tif (base === null || !Number.isInteger(mask) || mask < 0 || mask > 32) {\n\t\treturn null;\n\t}\n\tconst netmask = mask === 0 ? 0 : (0xFFFFFFFF << (32 - mask)) >>> 0;\n\tconst start = base & netmask;\n\tconst end = start | (~netmask >>> 0);\n\n\treturn [ toIPv4(start), toIPv4(end) ];\n}\n","import {\n\tnumToIpAddr,\n\tparseIPv4,\n} from '../index';\n\n/**\n * Converts a dotted-decimal IPv4 address string (e.g. `\"192.168.0.1\"`)\n * into its **32-bit unsigned integer** representation.\n *\n * @remarks\n * This function performs a strict validation of the IPv4 address and encodes\n * each of its four octets into a 32-bit number using **big-endian (network byte order)**.\n *\n * The resulting number is in the range `0..4_294_967_295` (`0xFFFFFFFF`),\n * where:\n *\n * - `\"0.0.0.0\"` → `0`\n * - `\"255.255.255.255\"` → `4294967295`\n *\n * This representation is particularly useful for:\n * - performing numeric range comparisons (e.g., IP ranges, CIDR checks);\n * - storing IPv4 values compactly in binary structures or databases;\n * - bitwise operations such as masking and subnet arithmetic.\n * \n * - The conversion uses a {@link DataView} and explicit byte writes\n *   to guarantee consistent big-endian behavior across platforms.\n * - The output number is safe for 32-bit unsigned arithmetic via `>>> 0`.\n * - If you need the inverse operation, see {@link numToIpAddr}.\n *\n * @param ip - The IPv4 address in dotted-quad string form.\n *\n * @returns A 32-bit **unsigned integer** representing the given IPv4 address.\n *\n * @example\n * ```ts\n * // Example 1: Simple conversion\n * ipAddrToNum(\"192.168.0.1\");\n * // -> 3232235521\n *\n * // Example 2: Edge values\n * ipAddrToNum(\"0.0.0.0\");       // -> 0\n * ipAddrToNum(\"255.255.255.255\"); // -> 4294967295\n * ```\n *\n * @example\n * ```ts\n * // Example 3: Invalid input\n * ipAddrToNum(\"192.168.1\");      // throws Error(\"Invalid IPv4 address\")\n * ipAddrToNum(\"256.0.0.1\");      // throws Error(\"Invalid IPv4 address\")\n * ipAddrToNum(\"abc.def.ghi.jkl\"); // throws Error(\"Invalid IPv4 address\")\n * ```\n *\n * @throws {Error}\n * Thrown when:\n * - The input does not contain exactly four parts separated by dots.\n * - Any octet is not an integer between 0 and 255 inclusive.\n *\n * @see {@link numToIpAddr} — converts a 32-bit integer back to an IPv4 string.\n * @see {@link parseIPv4} — similar numeric parser using bitwise operations.\n *\n * @public\n * @category Network & IP\n * @since 2.0.0\n */\nexport function ipAddrToNum(ip: string): number {\n\tconst parts = ip.split('.').map(p => Number(p));\n\n\tif (parts.length !== 4 || parts.some(p => !Number.isInteger(p) || p < 0 || p > 255)) {\n\t\tthrow new Error('Invalid IPv4 address');\n\t}\n\n\tconst buffer = new ArrayBuffer(4);\n\tconst dv = new DataView(buffer);\n\tlet i = 0;\n\n\twhile (i < 4) {\n\t\tdv.setUint8(i, parts[i]);\n\t\ti++;\n\t}\n\treturn dv.getUint32(0, false);\n}\n","import { \n\tisNumP,\n\tipAddrToNum, \n\tparseIPv4,\n} from '../index';\n\n/**\n * Converts a 32-bit unsigned integer (numeric IPv4 representation)\n * back into its dotted-decimal string form (e.g. `\"192.168.0.1\"`).\n *\n * @remarks\n * This is the inverse of {@link ipAddrToNum}.  \n * It interprets the input number as a **big-endian (network-byte-order)**\n * IPv4 value, extracting each of the four octets and joining them into\n * the standard dotted-quad notation.\n *\n * If the input is not a valid finite number (checked via {@link isNumP}),\n * an empty string `\"\"` is returned instead of throwing an exception.\n *\n * The resulting string always consists of **exactly four decimal octets**\n * separated by dots, with each octet in the range `0–255`.\n * \n * - Internally uses {@link DataView} to ensure consistent big-endian behavior\n *   across all platforms.\n * - The output format is always normalized (no leading zeros, no spaces).\n * - For the forward direction (string → number), see {@link ipAddrToNum}.\n *\n * @param num - The 32-bit unsigned integer representing an IPv4 address.\n *\n * @returns A dotted-decimal IPv4 string (e.g. `\"10.0.0.1\"`),  \n * or an empty string if the input is invalid.\n *\n * @example\n * ```ts\n * // Example 1: Basic conversion\n * numToIpAddr(3232235521);\n * // -> \"192.168.0.1\"\n *\n * // Example 2: Edge values\n * numToIpAddr(0);          // -> \"0.0.0.0\"\n * numToIpAddr(4294967295); // -> \"255.255.255.255\"\n * ```\n *\n * @example\n * ```ts\n * // Example 3: Invalid inputs\n * numToIpAddr(NaN);         // -> \"\"\n * numToIpAddr(Infinity);    // -> \"\"\n * numToIpAddr(-5);          // -> \"\"\n * ```\n *\n * @throws Never throws; invalid inputs simply return an empty string.\n *\n * @see {@link ipAddrToNum} — converts dotted IPv4 strings to numeric form.\n * @see {@link parseIPv4} — alternative parser using bitwise arithmetic.\n *\n * @public\n * @category Network & IP\n * @since 2.0.0\n */\nexport function numToIpAddr(num: number): string {\n\tif (!isNumP(num)) {\n\t\treturn '';\n\t}\n\tconst nbuffer = new ArrayBuffer(4);\n\tconst ndv = new DataView(nbuffer);\n\n\tndv.setUint32(0, num, false);\n\n\tconst output: number[] = [];\n\tlet i = 0;\n\t\n\twhile (i < 4) {\n\t\toutput.push(ndv.getUint8(i));\n\t\ti++;\n\t}\n\treturn output.join('.');\n}\n","import { \n\tisStr,\n\tformatToTrim, \n} from '../index';\n\n/**\n * Parses a dotted-quad IPv4 string (e.g. `\"192.168.0.1\"`) into a 32-bit unsigned integer.\n *\n * @remarks\n * The returned number is in the range `0..0xFFFFFFFF` and represents the IPv4 address\n * in big-endian order (i.e. the usual network order).\n *\n * The function is strict about format:\n * - Exactly 4 decimal octets separated by dots.\n * - Each octet must be `0..255`.\n * - Only digits are allowed in each octet.\n *\n * Leading zeros in octets are permitted (e.g. `\"001.002.003.004\"`), but you may\n * choose to forbid them in a custom variant to avoid legacy octal confusions.\n *\n * @param ip - Dotted-quad IPv4 string to parse.\n * @returns The IPv4 as an unsigned 32-bit number, or `null` if invalid.\n *\n * @example\n * ```ts\n * parseIPv4('127.0.0.1'); // 2130706433\n * parseIPv4('256.0.0.1'); // null\n * parseIPv4('1.2.3');     // null\n * ```\n *\n * @public\n * @category IPv4\n * @since 2.0.0\n */\nexport function parseIPv4(ip: string): number | null {\n\tif (!isStr(ip)) {\n\t\treturn null;\n\t}\n\tconst parts = formatToTrim(ip).split('.');\n\t\n\tif (parts.length !== 4) {\n\t\treturn null;\n\t}\n\tlet out = 0;\n\t\n\tfor (let i = 0; i < 4; i++) {\n\t\tif (!/^\\d{1,3}$/.test(parts[i])) {\n\t\t\treturn null;\n\t\t}\n\t\tconst n = Number(parts[i]);\n\t\t\n\t\tif (n < 0 || n > 255) {\n\t\t\treturn null;\n\t\t}\n\t\tout = (out << 8) | n;\n\t}\n\treturn out >>> 0;\n}\n","import type { RangeIPv4Options } from '../index';\nimport { \n\tcidrToRange,\n\tparseIPv4,\n\ttoIPv4, \n\trangeIPv4ToArr,\n} from '../index';\n\nfunction rangeIPv4(from: string, to?: string): Generator<string>;\n/**\n * Creates a lazy generator over an inclusive IPv4 range.\n *\n * @remarks\n * The function supports two input modes:\n *\n * 1. **CIDR mode** — when `from` contains a slash and `to` is `undefined`:\n *    ```ts\n *    for (const ip of rangeIPv4('192.168.1.0/30')) { ... }\n *    ```\n *    In this mode, {@link RangeIPv4Options.includeNetwork} and\n *    {@link RangeIPv4Options.includeBroadcast} are honored for masks `<= /30`.\n *    For `/31` and `/32` there is no traditional network/broadcast to exclude.\n *\n * 2. **Ad-hoc range mode** — when `from` is an IPv4 and `to` is either an IPv4\n *    or empty/omitted:\n *    - If `to` is provided, the range is `[min(from,to) .. max(from,to)]`.\n *    - If `to` is omitted or blank, the range spans to the end of the `/24`\n *      block: `A.B.C.D .. A.B.C.255`.\n *\n * The iteration is inclusive of both endpoints and is safe around the upper\n * bound: if the current value is `0xFFFFFFFF`, the generator yields it once and terminates.\n * \n * This is a lazy generator: it does **not** allocate the entire range up-front,\n * making it suitable for very large ranges (iterate/stream/process on the fly).\n * If you need a materialized array, consider {@link rangeIPv4ToArr} but mind its `limit`.\n *\n * @overload\n * @param from - A CIDR string (e.g. `\"10.0.0.0/8\"`). If this overload is used, `to` must be `undefined`.\n *\n * @overload\n * @param from - Starting IPv4 address in dotted-quad form.\n * @param to - Optional ending IPv4 address in dotted-quad form. If omitted or empty, the range ends at `A.B.C.255`.\n * @param opts - Iteration options.\n * @returns A generator of dotted-quad IPv4 strings.\n *\n * @param from - See overloads.\n * @param to - See overloads.\n * @param opts - See overloads.\n *\n * @example\n * ```ts\n * // 1) CIDR iteration (include all)\n * [...rangeIPv4('192.168.1.0/30')];\n * // -> ['192.168.1.0','192.168.1.1','192.168.1.2','192.168.1.3']\n *\n * // 2) CIDR iteration without network/broadcast\n * [...rangeIPv4('192.168.1.0/30', undefined, { includeNetwork: false, includeBroadcast: false })];\n * // -> ['192.168.1.1','192.168.1.2']\n *\n * // 3) Ad-hoc range (explicit end)\n * [...rangeIPv4('10.0.0.1', '10.0.0.4')];\n * // -> ['10.0.0.1','10.0.0.2','10.0.0.3','10.0.0.4']\n *\n * // 4) Single address ⇒ to end of /24\n * [...rangeIPv4('10.1.2.3')].at(-1); // '10.1.2.255'\n * ```\n *\n * @throws {Error}\n * - If `from` is not a valid IPv4 (in non-CIDR mode).\n * - If `to` is supplied and is not a valid IPv4 (in non-CIDR mode).\n * - If `from` is not a valid CIDR in CIDR mode.\n *\n * @see {@link cidrToRange} to convert a CIDR to `[ start, end ]`.\n * @see {@link rangeIPv4ToArr} to materialize a range into an array with a safe limit.\n * @public\n * @category IPv4\n * @since 2.0.0\n */\nfunction rangeIPv4(from: string, to: string | undefined, opts?: RangeIPv4Options): Generator<string>;\n\nfunction* rangeIPv4(from: string, to?: string, opts: RangeIPv4Options = {}): Generator<string> {\n\tconst { includeNetwork = true, includeBroadcast = true } = opts;\n\tlet startNum: number;\n\tlet endNum: number;\n\tlet isCIDR = false;\n\tlet cidrMask: number | null = null;\n\n\tif (to === undefined && from.includes('/')) {\n\t\tconst range = cidrToRange(from);\n\t\t\n\t\tif (!range) {\n\t\t\tthrow new Error(`Invalid CIDR: \"${from}\"`);\n\t\t}\n\t\tconst [ startStr, endStr ] = range;\n\t\tconst [ _, maskStr ] = from.split('/');\n\t\t\n\t\tcidrMask = Number(maskStr);\n\t\tstartNum = parseIPv4(startStr)!;\n\t\tendNum = parseIPv4(endStr)!;\n\t\tisCIDR = true;\n\t} \n\telse {\n\t\tconst s = parseIPv4(from);\n\t\t\n\t\tif (s === null) {\n\t\t\tthrow new Error(`Invalid IPv4: \"${from}\"`);\n\t\t}\n\t\tstartNum = s;\n\n\t\tif (to && to.trim() !== '') {\n\t\t\tconst e = parseIPv4(to);\n\t\t\t\n\t\t\tif (e === null) {\n\t\t\t\tthrow new Error(`Invalid IPv4: \"${to}\"`);\n\t\t\t}\n\t\t\tendNum = e;\n\t\t} \n\t\telse {\n\t\t\tconst a = (startNum >>> 24) & 255;\n\t\t\tconst b = (startNum >>> 16) & 255;\n\t\t\tconst c = (startNum >>> 8) & 255;\n\t\t\t\n\t\t\tendNum = ((a << 24) | (b << 16) | (c << 8) | 255) >>> 0;\n\t\t}\n\t}\n\tif (startNum > endNum) {\n\t\t[ startNum, endNum ] = [ endNum, startNum ];\n\t}\n\tlet skipNetworkAt = -1;\n\tlet skipBroadcastAt = -1;\n\t\n\tif (isCIDR && cidrMask !== null) {\n\t\tif (cidrMask <= 30) {\n\t\t\tskipNetworkAt = startNum;\n\t\t\tskipBroadcastAt = endNum;\n\t\t}\n\t}\n\tfor (let cur = startNum; cur <= endNum; cur = (cur + 1) >>> 0) {\n\t\tif (!includeNetwork && cur === skipNetworkAt) {\n\t\t\tif (cur === endNum) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\t\tif (!includeBroadcast && cur === skipBroadcastAt) {\n\t\t\tif (cur === endNum) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\t\tyield toIPv4(cur);\n\t\t\n\t\tif (cur === 0xFFFFFFFF) {\n\t\t\tbreak;\n\t\t}\n\t}\n}\n\nexport { rangeIPv4 };\n","import type { RangeIPv4Options } from '../index';\nimport { rangeIPv4 } from '../index';\n\n/**\n * Materializes an IPv4 range into an array of dotted-quad strings.\n *\n * @remarks\n * This is a convenience wrapper around the lazy {@link rangeIPv4} generator that\n * collects the yielded addresses into a new array. To protect against excessive\n * memory usage, a hard {@link RangeIPv4Options.limit | limit} is enforced\n * (default `1_000_000`). If the range exceeds the limit, an error is thrown and\n * **no** partial array is returned.\n *\n * Prefer using the generator for very large ranges, streaming the results into\n * your processing pipeline (e.g. writing to a file or socket).\n *\n * @param from - See {@link rangeIPv4} for accepted forms (CIDR or IPv4).\n * @param to - Optional end address (non-CIDR mode). Ignored for CIDR input.\n * @param opts - Options including the array size `limit`. See {@link RangeIPv4Options}.\n * @returns A new array with all IPv4 addresses in the range (inclusive).\n *\n * @example\n * ```ts\n * // Small range OK\n * rangeIPv4ToArray('192.168.1.10', '192.168.1.13');\n * // -> ['192.168.1.10','192.168.1.11','192.168.1.12','192.168.1.13']\n *\n * // Will throw if exceeds the limit\n * rangeIPv4ToArray('10.0.0.0/16', undefined, { limit: 10_000 }); // Error\n * ```\n *\n * @throws {Error} If the realized array would exceed `opts.limit`.\n * @see {@link rangeIPv4} for lazy iteration without materialization.\n * @public\n * @category IPv4\n * @since 2.0.0\n */\nexport function rangeIPv4ToArr(\n\tfrom: string,\n\tto?: string,\n\topts: RangeIPv4Options = {}\n): string[] {\n\tconst { limit = 1_000_000 } = opts;\n\tconst out: string[] = [];\n\tlet count = 0;\n\n\tfor (const ip of rangeIPv4(from, to, opts)) {\n\t\tif (count >= limit) {\n\t\t\tthrow new Error(`Range is too large (> ${limit}). Use the generator version instead.`);\n\t\t}\n\t\tout.push(ip);\n\t\tcount++;\n\t}\n\treturn out;\n}\n","import { parseIPv4 } from '../index';\n\n/**\n * Converts an unsigned 32-bit integer into a dotted-quad IPv4 string.\n *\n * @remarks\n * This is the inverse of {@link parseIPv4}. The function validates that the input\n * is a finite integer within `0..0xFFFFFFFF` and then formats it as `A.B.C.D`.\n *\n * @param n - Unsigned 32-bit IPv4 value (`0..0xFFFFFFFF`).\n * @returns A dotted-quad string such as `\"192.168.0.1\"`.\n *\n * @example\n * ```ts\n * toIPv4(0);            // \"0.0.0.0\"\n * toIPv4(0xFFFFFFFF);   // \"255.255.255.255\"\n * ```\n *\n * @throws {Error} If `n` is not an integer in `0..0xFFFFFFFF`.\n * @see {@link parseIPv4}\n * @public\n * @category IPv4\n * @since 2.0.0\n */\nexport function toIPv4(n: number): string {\n\tif (!Number.isInteger(n) || n < 0 || n > 0xFFFFFFFF) {\n\t\tthrow new Error(`Invalid IPv4 number: ${n}`);\n\t}\n\treturn [\n\t\t(n >>> 24) & 255,\n\t\t(n >>> 16) & 255,\n\t\t(n >>> 8) & 255,\n\t\tn & 255,\n\t].join('.');\n}\n","/**\n * Checks whether a given value is an array.\n *\n * @summary\n * A strongly typed wrapper around {@link Array.isArray}, with an enhanced TypeScript\n * type guard that asserts the value as a **readonly non-empty array** (`readonly [T, ...T[]]`).\n *\n * @typeParam T - The expected element type of the array (defaults to `unknown`).\n *\n * @param value - Any value to test.\n *\n * @returns `true` if the value is an array (of any kind), otherwise `false`.\n * The return type acts as a **type guard**, allowing TypeScript to infer that\n * `value` is a readonly array of `T` when the function returns `true`.\n *\n * @remarks\n * - Internally uses the native {@link Array.isArray} method.\n * - Works correctly across realms (e.g., iframes, worker contexts, etc.).\n * - The type guard ensures `value` is a **readonly non-empty array**, not just an empty list.\n *   This provides safer downstream access patterns when empty arrays are not expected.\n * - If you need to allow empty arrays, consider changing the type to `readonly T[]`.\n *\n * ### Performance\n * - Time complexity: **O(1)** — constant time native check.\n * - Space complexity: **O(1)**.\n *\n * ### Common pitfalls\n * - `isArr([])` → `true`, even though the static type is `readonly [T, ...T[]]`.\n *   TypeScript does not validate runtime emptiness; you should still check `value.length`.\n * - `isArr('abc')` → `false`\n * - `isArr({ length: 3 })` → `false`\n *\n * ### Examples\n *\n * @example\n * // Basic usage\n * isArr([1, 2, 3]); // => true\n * isArr('hello');    // => false\n * isArr({});         // => false\n *\n * @example\n * // With type inference\n * const val: unknown = [10, 20];\n * if (isArr<number>(val)) {\n *   // TypeScript now knows val: readonly [number, ...number[]]\n *   console.log(val[0]); // OK\n * }\n *\n * @example\n * // With mixed content\n * isArr([true, 'text', 123]); // => true\n *\n * @see Array.isArray\n *\n * @category Type Guards\n * @public\n * @since 2.0.0\n */\nexport function isArr<T = unknown>(value: unknown): value is readonly [T, ...T[]] {\n\treturn Array.isArray(value);\n}\n","import { isArr } from '../index';\n\n\n/**\n * Checks whether a value is a **non-empty array**.\n *\n * @summary\n * A strongly-typed type guard that returns `true` only if the input value is an array\n * (via {@link isArr}) and contains at least one element (`length > 0`).\n *  \n * Useful for narrowing unknown data to a **readonly non-empty tuple type**\n * (`readonly [T, ...T[]]`), which gives TypeScript safer access guarantees.\n *\n * @typeParam T - Expected element type of the array (defaults to `unknown`).\n *\n * @param value - Any value to test.\n *\n * @returns `true` if `value` is an array with at least one element; otherwise `false`.\n *\n * @remarks\n * ### Type narrowing\n * When this function returns `true`, TypeScript automatically infers that:\n * ```ts\n * value is readonly [T, ...T[]]\n * ```\n *  \n * That means inside the `if` block, you can safely access `value[0]`\n * without additional checks.\n *\n * ### Behavior\n * - Delegates the array check to {@link isArr}.\n * - Works with both mutable (`T[]`) and readonly arrays (`readonly T[]`).\n * - Does **not** mutate or clone the array.\n * - Returns `false` for:\n *   - Non-array values (`null`, `undefined`, `object`, `string`, etc.).\n *   - Empty arrays (`[]`).\n *\n * ### Performance\n * - Time complexity: **O(1)** (constant time check).\n * - Space complexity: **O(1)**.\n *\n * ### Examples\n *\n * @example\n * // Basic usage\n * isArrFilled([1, 2, 3]);  // => true\n * isArrFilled([]);          // => false\n *\n * @example\n * // With type inference\n * const maybeNumbers: unknown = [10, 20];\n * if (isArrFilled<number>(maybeNumbers)) {\n *   // value is now typed as: readonly [number, ...number[]]\n *   console.log(maybeNumbers[0]); // OK\n * }\n *\n * @example\n * // Non-array values\n * isArrFilled('abc');       // => false\n * isArrFilled(null);        // => false\n * isArrFilled(undefined);   // => false\n * isArrFilled({ length: 2 }); // => false\n *\n * @see isArr\n *\n * @category Type Guards\n * @public\n * @since 2.0.0\n */\nexport function isArrFilled<T = unknown>(value: unknown): value is readonly [ T, ...T[] ] {\n\treturn isArr(value) && value.length > 0;\n}\n","/**\n * Checks whether a given value is a boolean (`true` or `false`).\n *\n * @summary\n * A strict type guard that returns `true` only if `value` is of type `\"boolean\"`.\n *  \n * This helps safely narrow unknown or mixed-type values in TypeScript code,\n * especially when working with dynamic data sources, JSON, or user input.\n *\n * @param value - Any value to check.\n *\n * @returns `true` if the value is strictly a boolean, otherwise `false`.\n *\n * @remarks\n * - Uses the built-in `typeof` operator (`typeof value === \"boolean\"`).  \n * - Does **not** coerce values — only primitive `true` or `false` are accepted.\n * - Returns `false` for Boolean objects created via `new Boolean()`, because those\n *   are of type `\"object\"`, not `\"boolean\"`.\n * - Designed as a **type guard**, so when it returns `true`, TypeScript will infer:\n *   ```ts\n *   value is boolean\n *   ```\n *\n * ### Performance\n * - Time complexity: **O(1)** (constant).\n * - Space complexity: **O(1)**.\n *\n * ### Examples\n *\n * @example\n * // Basic usage\n * isBool(true);        // => true\n * isBool(false);       // => true\n * isBool(0);           // => false\n * isBool('true');      // => false\n *\n * @example\n * // With type narrowing\n * const val: unknown = Math.random() > 0.5 ? true : 'yes';\n * if (isBool(val)) {\n *   // TypeScript now knows val: boolean\n *   console.log(val ? 'OK' : 'NO');\n * }\n *\n * @example\n * // Boolean object is not accepted\n * isBool(new Boolean(true)); // => false\n *\n * @category Type Guards\n * @public\n * @since 2.0.0\n */\nexport function isBool(value: unknown): value is boolean {\n\treturn typeof value === 'boolean';\n}\n","import { \n\tisStr,\n\tisNum, \n} from '../index';\n\n/**\n * Checks whether a value represents a **valid JavaScript date**.\n *\n * @summary\n * Returns `true` if the given value is either:\n * - an actual `Date` instance with a valid timestamp, or\n * - a string or number that can be successfully parsed by the JavaScript `Date` constructor.\n *\n * Returns `false` for invalid dates (`Invalid Date`), empty strings, `NaN`, or non-date types.\n *\n * @param value - Any value to test (can be a `Date`, string, number, or other type).\n *\n * @returns `true` if the value can be interpreted as a valid date, otherwise `false`.\n *\n * @remarks\n * ### Validation logic\n * 1. **If `value` is a `Date` instance:**  \n *    Checks `!Number.isNaN(value.getTime())` — ensures it’s a real date, not an invalid one.\n *    ```ts\n *    isDate(new Date('invalid')); // false\n *    ```\n *\n * 2. **If `value` is a string or number:**  \n *    Attempts to construct a new `Date(value)`.  \n *    Returns `true` only if the resulting date’s timestamp is finite (not `NaN`).\n *\n * 3. **Otherwise:**  \n *    Returns `false`.\n *\n * ### What counts as \"valid\"\n * - OK: `\"2024-12-31\"`, `\"2024-12-31T23:59:59Z\"`, `1728000000000`, `new Date()`\n * - BAD: `\"abc\"`, `NaN`, `{}`, `null`, `undefined`, `new Date('invalid')`\n *\n * ### Type safety\n * - This is **not** a strict type guard (it doesn’t narrow to `Date`),  \n *   but you can pair it with a cast when `true`:\n *   ```ts\n *   if (isDate(v)) {\n *     const d = new Date(v); // guaranteed valid\n *   }\n *   ```\n *\n * ### Performance\n * - Time complexity: **O(1)**  \n *   (`Date` construction and timestamp check are constant-time operations).\n * - Space complexity: **O(1)**.\n *\n * ### Examples\n *\n * @example\n * // Valid Date instances\n * isDate(new Date());                  // => true\n * isDate(new Date('2024-05-01'));      // => true\n *\n * @example\n * // From strings or timestamps\n * isDate('2025-01-01T00:00:00Z');      // => true\n * isDate(1700000000000);               // => true\n * isDate('not-a-date');                // => false\n *\n * @example\n * // Invalid cases\n * isDate({});                          // => false\n * isDate([]);                          // => false\n * isDate('');                          // => false\n * isDate(new Date('invalid'));         // => false\n *\n * @see isStr\n * @see isNum\n * @see Date\n *\n * @category Type Guards\n * @public\n * @since 2.0.0\n */\nexport function isDate(value: unknown): boolean {\n\tif (value instanceof Date) {\n\t\treturn !Number.isNaN(value.getTime());\n\t}\n\tif (isStr(value) || isNum(value)) {\n\t\tconst d = new Date(value as any);\n\n\t\treturn !Number.isNaN(d.getTime());\n\t}\n\treturn false;\n}\n","import { isStrFilled } from '../index';\n\nconst emailRegex = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z]{2,})+$/;\n\n/**\n * Checks whether a given value is a **valid email address**.\n *\n * @summary\n * Validates that the input is a non-empty string and matches a simplified but\n * practical email pattern according to RFC 5322-compatible syntax rules.\n *\n * @param value - Any value to test (string or unknown).\n *\n * @returns `true` if the value is a non-empty string that looks like a valid email,  \n * otherwise `false`.\n *\n * @remarks\n * ### Validation process\n * 1. Ensures the input is a **non-empty string** via {@link isStrFilled}.\n * 2. Tests the value against a precompiled **regular expression**:\n *    ```\n *    /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+\n *     @[a-zA-Z0-9]\n *     (?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\n *     (?:\\.[a-zA-Z]{2,})+$/\n *    ```\n *    This allows standard ASCII characters in the local part and enforces:\n *    - at least one `@` separator  \n *    - valid domain and subdomain segments  \n *    - a top-level domain of at least two letters.\n *\n * ### Behavior notes\n * - Returns `false` for empty strings, `null`, `undefined`, or non-string inputs.\n * - Does **not** perform DNS or MX record validation — only syntactic matching.\n * - Intended for lightweight client-side or structural checks.\n * - If you need full compliance with RFC 6531 (Unicode / IDN), normalize the address first.\n *\n * ### Performance\n * - Time complexity: **O(n)** — proportional to input length.\n * - Space complexity: **O(1)**.\n * - The compiled regex is cached and reused for efficiency.\n *\n * ### Examples\n *\n * @example\n * // Valid emails\n * isEmail('user@example.com');           // => true\n * isEmail('john.doe+alias@mail.co.uk');  // => true\n *\n * @example\n * // Invalid formats\n * isEmail('');                           // => false\n * isEmail('user@');                      // => false\n * isEmail('@example.com');               // => false\n * isEmail('user@@example.com');          // => false\n * isEmail('user example@domain.com');    // => false\n *\n * @example\n * // Non-string inputs\n * isEmail(null);                         // => false\n * isEmail(undefined);                    // => false\n * isEmail(12345);                        // => false\n *\n * @see isStrFilled\n *\n * @category Validation\n * @public\n * @since 2.0.0\n */\nexport function isEmail(value: unknown): value is string {\n\tif (!isStrFilled(value)) {\n\t\treturn false;\n\t}\n\treturn emailRegex.test(value);\n}\n","/**\n * Checks whether a value **exists** — i.e. is neither `null` nor `undefined`.\n *\n * @summary\n * A minimal and strongly typed utility that acts as a **type guard**\n * to filter out `null` and `undefined` values in TypeScript.  \n * It is especially useful in array filters and conditional checks\n * where you need to ensure a value is \"present\".\n *\n * @typeParam T - The original type of the tested value.\n *\n * @param value - Any value that may be `null` or `undefined`.\n *\n * @returns `true` if `value` is not `null` and not `undefined`, otherwise `false`.\n *\n * @remarks\n * ### Type narrowing\n * When this function returns `true`, TypeScript automatically infers:\n * ```ts\n * value is T\n * ```\n *  \n * That means inside the `if` block (or after using `Array.filter(isExists)`),\n * the compiler knows the value cannot be `null` or `undefined`.\n *\n * ### Behavior\n * - Returns `false` for `null` and `undefined`.\n * - Returns `true` for any other type — including `false`, `0`, `''`, `NaN`, empty arrays, etc.\n * - The check is **strict** (`!==`) — no type coercion occurs.\n *\n * ### Typical use cases\n * - Filtering arrays that may contain `null` or `undefined`.\n * - Guarding optional values before access.\n * - Simplifying type-safe checks in functional chains.\n *\n * ### Performance\n * - Time complexity: **O(1)**\n * - Space complexity: **O(1)**\n *\n * ### Examples\n *\n * @example\n * // Basic checks\n * isExists(null);        // => false\n * isExists(undefined);   // => false\n * isExists(0);           // => true\n * isExists('');          // => true\n * isExists(false);       // => true\n *\n * @example\n * // With TypeScript narrowing\n * const val: string | null | undefined = getValue();\n * if (isExists(val)) {\n *   // val is now guaranteed to be a string\n *   console.log(val.toUpperCase());\n * }\n *\n * @example\n * // Filtering nullable arrays\n * const arr = [1, null, 2, undefined, 3];\n * const clean = arr.filter(isExists);\n * // clean: number[]  => [1, 2, 3]\n *\n * @category Type Guards\n * @public\n * @since 2.0.0\n */\nexport function isExists<T>(value: T | null | undefined): value is T {\n\treturn value !== null && value !== undefined;\n}\n","/**\n * Checks whether a given value is a **function**.\n *\n * @summary\n * A strict type guard that returns `true` only if `value` is a callable function.  \n * It works with regular functions, arrow functions, async functions, class constructors,\n * and built-in functions like `setTimeout`.\n *\n * @typeParam T - The expected function type to narrow to (defaults to the base `Function` type).\n *\n * @param value - Any value to check.\n *\n * @returns `true` if the value is of type `\"function\"`, otherwise `false`.\n *\n * @remarks\n * ### Type narrowing\n * When this function returns `true`, TypeScript infers that:\n * ```ts\n * value is T\n * ```\n *  \n * This allows safe calling of the function or using its specific signature.\n *\n * ### Behavior\n * - Returns `true` for:\n *   - Normal functions: `function test() {}`\n *   - Arrow functions: `() => {}`\n *   - Async functions: `async () => {}`\n *   - Generator functions: `function* gen() {}`\n *   - Class constructors (typeof `MyClass`).\n * - Returns `false` for:\n *   - Non-callable objects or primitives.\n *   - Function-like objects that aren't real functions (e.g., `{ call() {} }`).\n *\n * ### Performance\n * - Time complexity: **O(1)**\n * - Space complexity: **O(1)**\n *\n * ### Examples\n *\n * @example\n * // Basic usage\n * isFunc(() => {});           // => true\n * isFunc(function test() {}); // => true\n * isFunc(class A {});         // => true\n * isFunc(123);                // => false\n * isFunc({});                 // => false\n *\n * @example\n * // Type narrowing\n * const fn: unknown = () => 'ok';\n * if (isFunc<() => string>(fn)) {\n *   const result = fn(); // result: string\n * }\n *\n * @example\n * // Class constructors are also \"functions\"\n * class MyClass {}\n * isFunc(MyClass);            // => true\n *\n * @category Type Guards\n * @public\n * @since 2.0.0\n */\nexport function isFunc<T extends Function = Function>(value: unknown): value is T {\n\treturn typeof value === 'function';\n}\n","import { isStr } from '../index';\n\nconst IPV4_RE = /^(25[0-5]|2[0-4]\\d|[01]?\\d\\d?)\\.(25[0-5]|2[0-4]\\d|[01]?\\d\\d?)\\.(25[0-5]|2[0-4]\\d|[01]?\\d\\d?)\\.(25[0-5]|2[0-4]\\d|[01]?\\d\\d?)$/;\n\n/**\n * Checks whether a given value is a **valid IPv4 address**.\n *\n * @summary\n * Validates that the input is a string containing four octets (e.g. `\"192.168.0.1\"`),\n * where each octet is a number between `0` and `255`, separated by dots.\n *\n * @param value - Any value to test (string or unknown).\n *\n * @returns `true` if the value is a syntactically valid IPv4 address, otherwise `false`.\n *\n * @remarks\n * ### Validation steps\n * 1. Ensures the input is a string via {@link isStr}.\n * 2. Trims leading and trailing whitespace.\n * 3. Tests the cleaned string against a strict regular expression for IPv4 format:\n *    ```\n *    /^(25[0-5]|2[0-4]\\d|[01]?\\d\\d?)\\.\n *      (25[0-5]|2[0-4]\\d|[01]?\\d\\d?)\\.\n *      (25[0-5]|2[0-4]\\d|[01]?\\d\\d?)\\.\n *      (25[0-5]|2[0-4]\\d|[01]?\\d\\d?)$/\n *    ```\n *    Each group allows:\n *    - `0–9`, `00–99`, `100–199`, `200–249`, `250–255`\n *\n * ### Behavior notes\n * - Returns `false` for non-strings, empty strings, or malformed IPs.\n * - Does **not** support IPv6 (use a separate validator for that).\n * - Does **not** perform CIDR or subnet validation — only syntax checking.\n * - Leading zeros are allowed (e.g. `\"010.000.000.001\"` is accepted, as per regex).\n *\n * ### Performance\n * - Time complexity: **O(1)** (fixed regex evaluation).\n * - Space complexity: **O(1)**.\n *\n * ### Examples\n *\n * @example\n * // Valid IPv4 addresses\n * isIpAddr('192.168.0.1');     // => true\n * isIpAddr('8.8.8.8');         // => true\n * isIpAddr('0.0.0.0');         // => true\n * isIpAddr('255.255.255.255'); // => true\n *\n * @example\n * // Invalid IPv4 strings\n * isIpAddr('256.0.0.1');       // => false  (octet > 255)\n * isIpAddr('192.168.0');       // => false  (missing octet)\n * isIpAddr('192.168.0.1.5');   // => false  (too many octets)\n * isIpAddr('192.168.0.A');     // => false  (non-numeric)\n * isIpAddr('192,168,0,1');     // => false  (wrong separator)\n *\n * @example\n * // Non-string inputs\n * isIpAddr(12345);             // => false\n * isIpAddr(null);              // => false\n * isIpAddr(undefined);         // => false\n *\n * @see isStr\n *\n * @category Validation\n * @public\n * @since 2.0.0\n */\nexport function isIpAddr(value: unknown): value is string {\n\tif (!isStr(value)) {\n\t\treturn false;\n\t}\n\tconst v = value.trim();\n\t\n\treturn IPV4_RE.test(v);\n}\n","import { isStr } from '../index';\n\n/**\n * Checks whether a given value is a **valid MAC address**.\n *\n * @summary\n * Validates that the input is a string formatted as a standard 6-octet\n * MAC (Media Access Control) address, consisting of 12 hexadecimal digits\n * separated by either colons (`:`) or hyphens (`-`).\n *\n * @param value - Any value to test (typically a string from user input or network data).\n *\n * @returns `true` if the value matches the MAC address pattern, otherwise `false`.\n *\n * @remarks\n * ### Accepted formats\n * - `00:1A:2B:3C:4D:5E`\n * - `00-1A-2B-3C-4D-5E`\n * - Both uppercase and lowercase hexadecimal digits are allowed.\n * - Mixed separators (e.g., `\"00:1A-2B:3C-4D:5E\"`) are **not** accepted.\n *\n * ### Validation logic\n * 1. Confirms that `value` is a string via {@link isStr}.\n * 2. Uses the following regular expression:\n *    ```\n *    /^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$/\n *    ```\n *    which enforces:\n *    - Exactly 6 byte segments (`xx:xx:xx:xx:xx:xx` or `xx-xx-xx-xx-xx-xx`)\n *    - Each segment: two hexadecimal digits (`0–9`, `A–F`, `a–f`)\n *    - A consistent separator (`:` or `-`)\n *\n * ### Behavior notes\n * - Returns `false` for empty strings, non-strings, or malformed addresses.\n * - Does **not** support 8-octet EUI-64 or Cisco short 3-octet formats.\n * - Does **not** check for broadcast or multicast address semantics — only syntax.\n *\n * ### Performance\n * - Time complexity: **O(1)** (fixed regex match)\n * - Space complexity: **O(1)** (no allocations beyond regex)\n *\n * ### Examples\n *\n * @example\n * // Valid MAC addresses\n * isMacAddr('00:1A:2B:3C:4D:5E');  // => true\n * isMacAddr('AA-BB-CC-DD-EE-FF');  // => true\n * isMacAddr('ff:ff:ff:ff:ff:ff');  // => true\n *\n * @example\n * // Invalid MAC addresses\n * isMacAddr('00:1A:2B:3C:4D');     // => false   (too short)\n * isMacAddr('00:1A:2B:3C:4D:5E:7F'); // => false (too long)\n * isMacAddr('00:1A:2B:3C:4D:ZZ');  // => false   (invalid hex)\n * isMacAddr('001A.2B3C.4D5E');     // => false   (wrong format)\n * isMacAddr('');                   // => false\n *\n * @example\n * // Non-string values\n * isMacAddr(null);                 // => false\n * isMacAddr(undefined);            // => false\n * isMacAddr(123456);               // => false\n *\n * @see isStr\n * @see isIp\n *\n * @category Validation\n * @public\n * @since 2.0.0\n */\nexport function isMacAddr(value: unknown): value is string {\n\treturn isStr(value) && /^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$/.test(value);\n}\n","/**\n * Checks whether a given value is a **finite number**.\n *\n * @summary\n * A strict type guard that returns `true` only if `value` is of type `\"number\"`\n * and is a finite numeric value (not `NaN`, `Infinity`, or `-Infinity`).\n *\n * @param value - Any value to check.\n *\n * @returns `true` if the value is a finite number, otherwise `false`.\n *\n * @remarks\n * ### Behavior\n * - Uses the built-in `typeof` operator to ensure the value is a primitive number.\n * - Rejects special non-finite numeric values:\n *   - `NaN`\n *   - `Infinity`\n *   - `-Infinity`\n * - Does **not** coerce strings — `\"123\"` returns `false`.\n * - Works only with **number primitives**, not `Number` objects (`new Number(5)` returns `false`).\n *\n * ### Type narrowing\n * When this function returns `true`, TypeScript automatically infers:\n * ```ts\n * value is number\n * ```\n * allowing you to use numeric operators and arithmetic safely.\n *\n * ### Comparison with related checks\n * | Function       | Accepts                         | Rejects                        |\n * |----------------|---------------------------------|--------------------------------|\n * | `isNum`        | finite numbers only             | `NaN`, `Infinity`, non-numbers |\n * | `isNumP`       | positive finite numbers         | `0`, negatives, `NaN`          |\n * | `isNumNZ`      | zero or negative finite numbers | positives, `NaN`               |\n *\n * ### Performance\n * - Time complexity: **O(1)**\n * - Space complexity: **O(1)**\n *\n * ### Examples\n *\n * @example\n * // Valid finite numbers\n * isNum(42);           // => true\n * isNum(0);            // => true\n * isNum(-3.14);        // => true\n *\n * @example\n * // Invalid numeric values\n * isNum(NaN);          // => false\n * isNum(Infinity);     // => false\n * isNum(-Infinity);    // => false\n *\n * @example\n * // Non-number inputs\n * isNum('123');        // => false\n * isNum(true);         // => false\n * isNum(null);         // => false\n * isNum(undefined);    // => false\n *\n * @example\n * // TypeScript narrowing\n * const x: unknown = 100;\n * if (isNum(x)) {\n *   console.log(x.toFixed(2)); // OK — x is number\n * }\n *\n * @category Type Guards\n * @public\n * @since 2.0.0\n */\nexport function isNum(value: unknown): value is number {\n\treturn (typeof value === 'number') && Number.isFinite(value);\n}\n","import { isNum } from '../index';\n\n/**\n * Checks whether a given value is a **finite non-integer (floating-point) number**.\n *\n * @summary\n * Returns `true` if the value is a finite number and **has a fractional part**\n * (i.e. not an integer).  \n * Acts as a strict type guard for float-like numeric values.\n *\n * @param value - Any value to test.\n *\n * @returns `true` if the value is a finite, non-integer number; otherwise `false`.\n *\n * @remarks\n * ### Behavior\n * - First verifies that the value is a finite number via {@link isNum}.\n * - Then ensures it is **not** an integer using `!Number.isInteger(value)`.\n * - Rejects all non-numeric, `NaN`, or infinite values.\n *\n * ### Comparison with related checks\n * | Function       | Matches                        | Rejects                            |\n * |----------------|--------------------------------|------------------------------------|\n * | `isNum`        | any finite number              | `NaN`, `Infinity`, `-Infinity`     |\n * | `isNumFloat`   | finite numbers **with fraction** | integers, `NaN`, non-numbers     |\n * | `isNumInt`     | finite **integers** only       | floats, `NaN`, non-numbers         |\n *\n * ### Performance\n * - Time complexity: **O(1)**  \n * - Space complexity: **O(1)**\n *\n * ### Examples\n *\n * @example\n * // Valid floats\n * isNumFloat(3.14);       // => true\n * isNumFloat(-0.001);     // => true\n * isNumFloat(1 / 3);      // => true\n *\n * @example\n * // Integers\n * isNumFloat(0);          // => false\n * isNumFloat(42);         // => false\n * isNumFloat(-7);         // => false\n *\n * @example\n * // Invalid or non-number values\n * isNumFloat(NaN);        // => false\n * isNumFloat(Infinity);   // => false\n * isNumFloat('3.14');     // => false\n * isNumFloat(null);       // => false\n *\n * @example\n * // Type narrowing\n * const val: unknown = 12.5;\n * if (isNumFloat(val)) {\n *   const n = val * 2; // val is number\n * }\n *\n * @see isNum\n * @see Number.isInteger\n *\n * @category Type Guards\n * @public\n * @since 2.0.0\n */\nexport function isNumFloat(value: unknown): value is number {\n\treturn isNum(value) && !Number.isInteger(value);\n}\n","import { isNum } from '../index';\n\n/**\n * Checks whether a given value is a **negative finite number**.\n *\n * @summary\n * A strict type guard that returns `true` only if the input is a finite number\n * and its value is **less than 0**.  \n * Useful for safely detecting negative numeric values without coercion.\n *\n * @param value - Any value to test.\n *\n * @returns `true` if the value is a finite number less than zero, otherwise `false`.\n *\n * @remarks\n * ### Behavior\n * - Relies on {@link isNum} to ensure the value is a finite number (not `NaN`, `Infinity`, etc.).\n * - Then checks `value < 0`.\n * - Returns `false` for zero, positive numbers, and all non-numeric types.\n *\n * ### Comparison with related checks\n * | Function     | Description                            | Condition                   |\n * |--------------|----------------------------------------|-----------------------------|\n * | `isNum`      | Any finite number                      | `Number.isFinite(value)`    |\n * | `isNumP`     | Positive numbers only                  | `value > 0`                 |\n * | `isNumN`     | Negative numbers only                  | `value < 0`                 |\n * | `isNumNZ`    | Negative or zero numbers               | `value <= 0`                |\n * | `isNumFloat` | Finite non-integer (fractional) numbers | `!Number.isInteger(value)` |\n *\n * ### Performance\n * - Time complexity: **O(1)**  \n * - Space complexity: **O(1)**\n *\n * ### Examples\n *\n * @example\n * // Negative numbers\n * isNumN(-1);          // => true\n * isNumN(-3.14);       // => true\n * isNumN(-0.0001);     // => true\n *\n * @example\n * // Non-negative numbers\n * isNumN(0);           // => false\n * isNumN(1);           // => false\n * isNumN(42);          // => false\n *\n * @example\n * // Invalid values\n * isNumN(NaN);         // => false\n * isNumN('-5');        // => false\n * isNumN(null);        // => false\n * isNumN(undefined);   // => false\n *\n * @example\n * // Type narrowing\n * const val: unknown = -12;\n * if (isNumN(val)) {\n *   const abs = Math.abs(val); // val is number\n * }\n *\n * @see isNum\n * @see isNumP\n * @see isNumNZ\n * @see isNumFloat\n *\n * @category Type Guards\n * @public\n * @since 2.0.0\n */\nexport function isNumN(value: unknown): value is number {\n\treturn isNum(value) && value < 0;\n}\n","import { isNum } from '../index';\n\n/**\n * Checks whether a given value is a **finite number that is less than or equal to zero**.\n *\n * @summary\n * A strict type guard that returns `true` if the input is a finite number and\n * its value is **negative or zero**.  \n * Commonly used to identify non-positive numeric values.\n *\n * @param value - Any value to test.\n *\n * @returns `true` if the value is a finite number less than or equal to zero; otherwise `false`.\n *\n * @remarks\n * ### Behavior\n * - Uses {@link isNum} to ensure the input is a finite number (rejects `NaN`, `Infinity`, etc.).\n * - Then checks the condition `value <= 0`.\n * - Returns `false` for all positive numbers and non-numeric values.\n *\n * ### Comparison with related checks\n * | Function     | Description                       | Condition      |\n * |--------------|-----------------------------------|----------------|\n * | `isNum`      | Any finite number                 | —              |\n * | `isNumP`     | Positive numbers only             | `value > 0`    |\n * | `isNumN`     | Negative numbers only             | `value < 0`    |\n * | `isNumNZ`    | Negative **or zero** numbers      | `value <= 0`   |\n * | `isNumFloat` | Finite non-integer (fractional)   | `!Number.isInteger(value)` |\n *\n * ### Performance\n * - Time complexity: **O(1)**  \n * - Space complexity: **O(1)**\n *\n * ### Examples\n *\n * @example\n * // Negative and zero values\n * isNumNZ(-1);          // => true\n * isNumNZ(-0.5);        // => true\n * isNumNZ(0);           // => true\n *\n * @example\n * // Positive values\n * isNumNZ(0.0001);      // => false\n * isNumNZ(5);           // => false\n *\n * @example\n * // Invalid or non-numeric inputs\n * isNumNZ('0');         // => false\n * isNumNZ(NaN);         // => false\n * isNumNZ(Infinity);    // => false\n * isNumNZ(null);        // => false\n *\n * @example\n * // Type narrowing\n * const x: unknown = -10;\n * if (isNumNZ(x)) {\n *   console.log(x.toFixed(2)); // x is number\n * }\n *\n * @see isNum\n * @see isNumP\n * @see isNumN\n * @see isNumFloat\n *\n * @category Type Guards\n * @public\n * @since 2.0.0\n */\nexport function isNumNZ(value: unknown): value is number {\n\treturn isNum(value) && value <= 0;\n}\n","import { isNum } from '../index';\n\n/**\n * Checks whether a given value is a **positive finite number**.\n *\n * @summary\n * A strict type guard that returns `true` only if the input is a finite number\n * greater than zero (`> 0`).  \n * Useful for safely validating numeric values that must be positive — such as\n * counters, IDs, amounts, or dimensions.\n *\n * @param value - Any value to test.\n *\n * @returns `true` if the value is a finite positive number, otherwise `false`.\n *\n * @remarks\n * ### Behavior\n * - Uses {@link isNum} to ensure the input is a finite number (`NaN`, `Infinity`, and `-Infinity` are rejected).\n * - Returns `true` only when `value > 0`.\n * - Returns `false` for zero, negative, or non-numeric values.\n *\n * ### Comparison with related checks\n * | Function     | Description                       | Condition                  |\n * |--------------|-----------------------------------|----------------------------|\n * | `isNum`      | Any finite number                 | —                          |\n * | `isNumP`     | Positive numbers only             | `value > 0`                |\n * | `isNumN`     | Negative numbers only             | `value < 0`                |\n * | `isNumNZ`    | Negative **or zero** numbers      | `value <= 0`               |\n * | `isNumFloat` | Finite non-integer (fractional)   | `!Number.isInteger(value)` |\n *\n * ### Performance\n * - Time complexity: **O(1)**  \n * - Space complexity: **O(1)**\n *\n * ### Examples\n *\n * @example\n * // Positive values\n * isNumP(1);           // => true\n * isNumP(3.14);        // => true\n * isNumP(0.00001);     // => true\n *\n * @example\n * // Zero and negatives\n * isNumP(0);           // => false\n * isNumP(-1);          // => false\n * isNumP(-0.5);        // => false\n *\n * @example\n * // Invalid or non-numeric inputs\n * isNumP('5');         // => false\n * isNumP(NaN);         // => false\n * isNumP(Infinity);    // => false\n * isNumP(null);        // => false\n *\n * @example\n * // Type narrowing\n * const x: unknown = 12;\n * if (isNumP(x)) {\n *   console.log(x.toFixed(1)); // x is number\n * }\n *\n * @see isNum\n * @see isNumN\n * @see isNumNZ\n * @see isNumFloat\n *\n * @category Type Guards\n * @public\n * @since 2.0.0\n */\nexport function isNumP(value: unknown): value is number {\n\treturn isNum(value) && value > 0;\n}\n","import { isNum } from '../index';\n\n/**\n * Checks whether a given value is a **finite number greater than or equal to zero**.\n *\n * @summary\n * A strict type guard that returns `true` if the input is a finite number\n * and its value is **non-negative** (`≥ 0`).  \n * Useful for safely validating values such as counters, sizes, durations,\n * and other quantities that cannot be negative.\n *\n * @param value - Any value to test.\n *\n * @returns `true` if the value is a finite number greater than or equal to zero; otherwise `false`.\n *\n * @remarks\n * ### Behavior\n * - Uses {@link isNum} to ensure the input is a finite number (`NaN`, `Infinity`, `-Infinity` are rejected).\n * - Returns `true` when `value >= 0`.\n * - Returns `false` for negative numbers or non-numeric inputs.\n *\n * ### Comparison with related checks\n * | Function     | Description                      | Condition                  |\n * |--------------|----------------------------------|----------------------------|\n * | `isNum`      | Any finite number                | —                          |\n * | `isNumP`     | Positive numbers only            | `value > 0`                |\n * | `isNumPZ`    | Non-negative numbers (`≥ 0`)     | `value >= 0`               |\n * | `isNumN`     | Negative numbers only            | `value < 0`                |\n * | `isNumNZ`    | Negative or zero numbers         | `value <= 0`               |\n * | `isNumFloat` | Finite non-integer numbers       | `!Number.isInteger(value)` |\n *\n * ### Performance\n * - Time complexity: **O(1)**  \n * - Space complexity: **O(1)**\n *\n * ### Examples\n *\n * @example\n * // Non-negative numbers\n * isNumPZ(0);           // => true\n * isNumPZ(5);           // => true\n * isNumPZ(3.14);        // => true\n *\n * @example\n * // Negative numbers\n * isNumPZ(-1);          // => false\n * isNumPZ(-0.1);        // => false\n *\n * @example\n * // Invalid or non-numeric inputs\n * isNumPZ('10');        // => false\n * isNumPZ(NaN);         // => false\n * isNumPZ(Infinity);    // => false\n * isNumPZ(null);        // => false\n *\n * @example\n * // Type narrowing\n * const val: unknown = 7;\n * if (isNumPZ(val)) {\n *   console.log(Math.sqrt(val)); // val is number\n * }\n *\n * @see isNum\n * @see isNumP\n * @see isNumN\n * @see isNumNZ\n * @see isNumFloat\n *\n * @category Type Guards\n * @public\n * @since 2.0.0\n */\nexport function isNumPZ(value: unknown): value is number {\n\treturn isNum(value) && value >= 0;\n}\n","/**\n * Checks whether a given value is a **plain object** (i.e. `{}`), not `null`, not an array, and not a class instance.\n *\n * @summary\n * A strict type guard that returns `true` only if the input is a plain object\n * created using an object literal (`{}`) or `Object.create(null)`.  \n * Excludes arrays, functions, `null`, and instances of custom classes.\n *\n * @param value - Any value to test.\n *\n * @returns `true` if the value is a non-null, non-array plain object; otherwise `false`.\n *\n * @remarks\n * ### Behavior\n * The check ensures all of the following:\n * 1. `typeof value === \"object\"` — confirms the value is object-like.\n * 2. `value !== null` — excludes `null`, since `typeof null === \"object\"`.\n * 3. `Object.prototype.toString.call(value) === \"[object Object]\"` — filters out built-ins like `Map`, `Set`, `Date`, etc.\n * 4. `!Array.isArray(value)` — ensures arrays are excluded.\n *\n * ### What counts as a \"plain object\"\n * `{}`, `{ a: 1 }`, `Object.create(null)`  \n * `[]`, `new Date()`, `new Map()`, `null`, class instances.\n *\n * ### Comparison with related concepts\n * | Example value           | Result | Explanation                      |\n * |--------------------------|---------|----------------------------------|\n * | `{}`                     | true | Plain object                     |\n * | `Object.create(null)`    | true | No prototype but still object     |\n * | `[]`                     | false | Array excluded                   |\n * | `null`                   | false | Explicitly filtered              |\n * | `new Date()`             | false | Built-in class instance          |\n * | `class A {}; new A()`    | false | Custom class instance            |\n *\n * ### Type narrowing\n * When this function returns `true`, TypeScript infers:\n * ```ts\n * value is Record<string, unknown>\n * ```\n * allowing safe property access and iteration.\n *\n * ### Performance\n * - Time complexity: **O(1)**\n * - Space complexity: **O(1)**\n *\n * ### Examples\n *\n * @example\n * // Plain objects\n * isObj({});                   // => true\n * isObj({ key: 'value' });     // => true\n * isObj(Object.create(null));  // => true\n *\n * @example\n * // Non-objects or special cases\n * isObj(null);                 // => false\n * isObj([]);                   // => false\n * isObj(new Date());           // => false\n * isObj(new Map());            // => false\n * isObj(() => {});             // => false\n *\n * @example\n * // Type narrowing\n * const val: unknown = { x: 1 };\n * if (isObj(val)) {\n *   console.log(val.x); // safe: val is Record<string, unknown>\n * }\n *\n * @category Type Guards\n * @public\n * @since 2.0.0\n */\nexport function isObj(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === 'object' \n\t\t&& value !== null \n\t\t&& Object.prototype.toString.call(value) === '[object Object]'\n\t\t&& !Array.isArray(value);\n}\n","import { isObj } from '../index';\n\n/**\n * Checks whether a given value is a **non-empty plain object**.\n *\n * @summary\n * A strict type guard that returns `true` only if the input is a plain object\n * (validated by {@link isObj}) **and** has at least one own enumerable key.  \n * In other words, it must be an object literal like `{ a: 1 }`, not `{}`.\n *\n * @param value - Any value to test.\n *\n * @returns `true` if the value is a plain object with at least one own property; otherwise `false`.\n *\n * @remarks\n * ### Behavior\n * - Uses {@link isObj} to verify the value is a plain object (not `null`, not an array, not a class instance).\n * - Calls `Object.keys(value).length > 0` to ensure the object has one or more keys.\n * - Returns `false` for empty objects (`{}`), arrays, functions, `null`, and other non-object types.\n *\n * ### Comparison with related checks\n * | Function         | Description                           | Example              |\n * |------------------|---------------------------------------|----------------------|\n * | `isObj`          | Checks if value is a plain object      | `{}` true / `[]` false |\n * | `isObjFilled`    | Checks if plain object is **non-empty** | `{a: 1}` true / `{}` false |\n * | `isArrFilled`    | Checks if array is non-empty           | `[1]` true / `[]` false |\n * | `isStrFilled`    | Checks if string is non-empty          | `'a'` true / `''` false |\n *\n * ### Type narrowing\n * When this function returns `true`, TypeScript infers:\n * ```ts\n * value is Record<string, unknown>\n * ```\n * allowing safe property access and iteration.\n *\n * ### Performance\n * - Time complexity: **O(n)** — proportional to the number of object keys.\n * - Space complexity: **O(1)**.\n *\n * ### Examples\n *\n * @example\n * // Non-empty plain objects\n * isObjFilled({ a: 1 });        // => true\n * isObjFilled({ key: null });   // => true\n * isObjFilled({ nested: {} });  // => true\n *\n * @example\n * // Empty or invalid objects\n * isObjFilled({});              // => false\n * isObjFilled([]);              // => false\n * isObjFilled(null);            // => false\n * isObjFilled(new Date());      // => false\n *\n * @example\n * // Type narrowing\n * const data: unknown = { x: 5 };\n * if (isObjFilled(data)) {\n *   console.log(Object.keys(data)); // safe\n * }\n *\n * @see isObj\n * @see isArrFilled\n * @see isStrFilled\n *\n * @category Type Guards\n * @public\n * @since 2.0.0\n */\nexport function isObjFilled(value: unknown): value is Record<string, unknown> {\n\treturn isObj(value) && Object.keys(value).length > 0;\n}\n","import type { PasswordOptions } from '../index';\nimport { isStr } from '../index';\n\n/**\n * Validates whether a string meets configurable **password strength requirements**.\n *\n * @summary\n * A flexible password validation helper that checks for length, uppercase and lowercase letters,\n * digits, and special characters.  \n * All rules are configurable through the optional {@link PasswordOptions} parameter.\n *\n * @param value - The value to validate as a password.\n * @param options - Optional validation rules (see {@link PasswordOptions}).  \n * Defaults ensure strong password requirements:\n * ```ts\n * {\n *   minLength: 8,\n *   maxLength: 256,\n *   requireUppercase: true,\n *   requireLowercase: true,\n *   requireDigit: true,\n *   requireSpecial: true\n * }\n * ```\n *\n * @returns `true` if the value is a valid string matching all configured requirements, otherwise `false`.\n *\n * @remarks\n * ### Behavior\n * 1. Ensures `value` is a string using {@link isStr}.\n * 2. Enforces **length limits** (`minLength` ≤ length ≤ `maxLength`).\n * 3. Optionally checks for:\n *    - Uppercase characters (Latin or Cyrillic): `/[A-ZА-Я]/`\n *    - Lowercase characters (Latin or Cyrillic): `/[a-zа-я]/`\n *    - Digits: `/\\d/`\n *    - Special characters: `/[~!?@#$%^&*_\\-+()\\[\\]{}><\\\\\\/|\"'.,:;=]/`\n * 4. Returns `true` only if all active checks pass.\n *\n * ### Default rule set (strong password)\n * - At least 8 characters long  \n * - Contains uppercase and lowercase letters  \n * - Contains at least one digit  \n * - Contains at least one special symbol  \n * - Not longer than 256 characters\n *\n * ### Example configuration\n * ```ts\n * // Minimal check — only length between 6 and 20\n * isPassword('abcdef', { minLength: 6, maxLength: 20, requireSpecial: false });\n *\n * // Strict corporate policy\n * isPassword('Qwerty#123', { minLength: 10, requireSpecial: true });\n *\n * // Simplified mobile app rule\n * isPassword('myPass1', { requireSpecial: false });\n * ```\n *\n * ### Type narrowing\n * When this function returns `true`, TypeScript infers:\n * ```ts\n * value is string\n * ```\n * allowing you to safely treat it as a verified password.\n *\n * ### Performance\n * - Time complexity: **O(n)** (depends on string length and regex scans).\n * - Space complexity: **O(1)**.\n *\n * ### Examples\n *\n * @example\n * // Default strong policy (8+ chars, upper, lower, digit, special)\n * isPassword('Aa1@aaaa');        // => true\n * isPassword('Password123!');    // => true\n * isPassword('qwerty');          // => false (no upper/digit/special)\n *\n * @example\n * // Custom rules\n * isPassword('abc123', {\n *   minLength: 6,\n *   requireUppercase: false,\n *   requireSpecial: false\n * }); // => true\n *\n * @example\n * // Invalid inputs\n * isPassword('');                // => false\n * isPassword(null);              // => false\n * isPassword(undefined);         // => false\n * isPassword(123456);            // => false\n *\n * @see isStr\n *\n * @category Validation\n * @public\n * @since 2.0.0\n */\nexport function isPassword(\n\tvalue: unknown,\n\t{\n\t\tminLength = 8,\n\t\tmaxLength = 256,\n\t\trequireUppercase = true,\n\t\trequireLowercase = true,\n\t\trequireDigit = true,\n\t\trequireSpecial = true,\n\t}: PasswordOptions = {}\n): value is string {\n\tif (!isStr(value)) {\n\t\treturn false;\n\t}\n\tif (value.length < minLength || value.length > maxLength) {\n\t\treturn false;\n\t}\n\tif (requireUppercase && !/[A-ZА-Я]/.test(value)) {\n\t\treturn false;\n\t}\n\tif (requireLowercase && !/[a-zа-я]/.test(value)) {\n\t\treturn false;\n\t}\n\tif (requireDigit && !/\\d/.test(value)) {\n\t\treturn false;\n\t}\n\tif (requireSpecial && !/[~!?@#$%^&*_\\-+()\\[\\]{}><\\\\\\/|\"'.,:;=]/.test(value)) {\n\t\treturn false;\n\t}\n\treturn true;\n}\n","import { \n\tisStrFilled,\n\tisNum, \n} from '../index';\n\n/**\n * Checks whether a given value is a **valid phone number** in a generic international format.\n *\n * @summary\n * A flexible, language-neutral phone number validator that accepts both string and numeric inputs.  \n * It supports optional leading `\"+\"`, allows dashes (`\"-\"`) as separators, and ensures that the\n * number structure is syntactically valid — not necessarily region-specific.\n *\n * @param value - Any value to test (string or number).\n *\n * @returns `true` if the value represents a valid phone-like number, otherwise `false`.\n *\n * @remarks\n * ### Validation logic\n * 1. **Type check:**  \n *    Accepts strings and finite numbers (`isStrFilled` or `isNum` must pass).\n * 2. **Normalization:**  \n *    Converts to string and trims whitespace.\n * 3. **Negative or misplaced signs:**  \n *    Rejects numbers starting with `\"-\"`.\n * 4. **Plus sign validation:**  \n *    - Only one `+` is allowed.  \n *    - If present, it must appear **only at the start**.\n * 5. **Character whitelist:**  \n *    The number must match the pattern `/^\\+?[0-9-]+$/`,  \n *    i.e., only digits, dashes, and an optional leading plus sign.\n * 6. **Length check:**  \n *    Must be between **3** and **20** characters (inclusive).\n * 7. **Ending rule:**  \n *    The last character must be a digit.\n * 8. **Double-dash check:**  \n *    Rejects sequences containing `\"--\"`.\n *\n * ### Behavior\n * - Accepts: `+1234567890`, `380-67-123-4567`, `79001234567`, `12345`.\n * - Rejects: `\"--123\"`, `\"++123\"`, `\"12a34\"`, `\"12 34\"`, `\"-123\"`, `\"123-\"`.\n * - Not region-specific — does **not** check country codes or local dialing rules.\n * - Designed for structural validation only.\n *\n * ### Comparison\n * | Example              | Valid | Reason                          |\n * |----------------------|:------:|--------------------------------|\n * | `+380671234567`      | true | Proper international format      |\n * | `067-123-4567`       | true | Local format with dashes         |\n * | `123`                | true | Minimum valid length             |\n * | `+12-34-56--78`      | false | Contains `\"--\"`                 |\n * | `+12A345`            | false | Contains letters                |\n * | `123-`               | false | Ends with non-digit             |\n * | `++38050`            | false | Multiple `\"+\"` symbols          |\n * | `380+501234`         | false | Misplaced plus                  |\n *\n * ### Type narrowing\n * When this function returns `true`, TypeScript infers:\n * ```ts\n * value is string\n * ```\n * even if the original value was numeric — ensuring it can be safely stored or formatted as text.\n *\n * ### Performance\n * - Time complexity: **O(n)** — single regex checks and scans.\n * - Space complexity: **O(1)**.\n *\n * ### Examples\n *\n * @example\n * // Valid international numbers\n * isPhone('+380671234567');     // => true\n * isPhone('380-67-123-4567');   // => true\n * isPhone(380501234567);        // => true\n *\n * @example\n * // Invalid formats\n * isPhone('--12345');            // => false\n * isPhone('+12+34');             // => false\n * isPhone('12A345');             // => false\n * isPhone('123-');               // => false\n * isPhone('');                   // => false\n *\n * @example\n * // Type narrowing\n * const val: unknown = '+14155552671';\n * if (isPhone(val)) {\n *   console.log(val.replace(/\\D/g, '')); // safe normalization\n * }\n *\n * @see isStrFilled\n * @see isNum\n * @see formatToPhone\n *\n * @category Validation\n * @public\n * @since 2.0.0\n */\nexport function isPhone(value: unknown): value is string {\n\tif (!isStrFilled(value) \n\t\t&& !isNum(value)) {\n\t\treturn false;\n\t}\n\tconst valueProcessed = String(value).trim();\n\n\tif (valueProcessed.startsWith('-')) {\n\t\treturn false;\n\t}\n\tif ((valueProcessed.match(/\\+/g) || []).length > 1) {\n\t\treturn false;\n\t}\n\tif (valueProcessed.includes('+') && !valueProcessed.startsWith('+')) {\n\t\treturn false;\n\t}\n\tif (!/^\\+?[0-9-]+$/.test(valueProcessed)) {\n\t\treturn false;\n\t}\n\tif (valueProcessed.length < 3 || valueProcessed.length > 20) {\n\t\treturn false;\n\t}\n\tif (!/[0-9]$/.test(valueProcessed)) {\n\t\treturn false;\n\t}\n\tif (valueProcessed.includes('--')) {\n\t\treturn false;\n\t}\n\treturn true;\n}\n","/**\n * Checks whether a given value is a **string** primitive.\n *\n * @summary\n * A strict type guard that returns `true` only if the provided value\n * has the JavaScript type `\"string\"`.  \n * Rejects all non-string types, including `String` objects created via `new String()`.\n *\n * @param value - Any value to test.\n *\n * @returns `true` if the value is a string primitive, otherwise `false`.\n *\n * @remarks\n * ### Behavior\n * - Uses the `typeof` operator for a strict type check.\n * - Does **not** coerce values — `\"123\"` is valid, but `123` is not.\n * - Returns `false` for:\n *   - `String` wrapper objects (`new String('abc')`)\n *   - Non-string types (`number`, `boolean`, `object`, `undefined`, etc.)\n *\n * ### Type narrowing\n * When this function returns `true`, TypeScript infers:\n * ```ts\n * value is string\n * ```\n * enabling full access to string methods safely.\n *\n * ### Comparison\n * | Input            | Result | Note                              |\n * |------------------|:------:|-----------------------------------|\n * | `'hello'`        | true  | String literal                     |\n * | `new String('x')`| false | Object wrapper, not primitive      |\n * | `123`            | false | Number                             |\n * | `null`           | false | Not a string                       |\n * | `undefined`      | false | Not a string                       |\n *\n * ### Performance\n * - Time complexity: **O(1)**  \n * - Space complexity: **O(1)**\n *\n * ### Examples\n *\n * @example\n * // Basic usage\n * isStr('Hello');       // => true\n * isStr('');            // => true\n * isStr(123);           // => false\n * isStr(null);          // => false\n *\n * @example\n * // Type narrowing\n * const val: unknown = 'abc';\n * if (isStr(val)) {\n *   console.log(val.toUpperCase()); // safe\n * }\n *\n * @category Type Guards\n * @public\n * @since 2.0.0\n */\nexport function isStr(value: unknown): value is string {\n\treturn typeof value === 'string';\n}\n","import { isStrFilled } from '../index';\n\n/**\n * Checks whether a given value is a **string representation of a boolean** — `\"true\"` or `\"false\"`.\n *\n * @summary\n * A strict type guard that returns `true` if the input is a non-empty string\n * equal to `\"true\"` or `\"false\"` (case-insensitive, with whitespace ignored).  \n * Commonly used for validating query parameters, environment variables, or serialized booleans.\n *\n * @param value - Any value to test.\n *\n * @returns `true` if the value is a string `\"true\"` or `\"false\"` (ignoring case and whitespace), otherwise `false`.\n *\n * @remarks\n * ### Behavior\n * 1. Uses {@link isStrFilled} to ensure the input is a non-empty string.\n * 2. Trims whitespace and converts it to lowercase.\n * 3. Returns `true` only if the normalized string equals `\"true\"` or `\"false\"`.\n * 4. Returns `false` for other strings, numbers, or non-string types.\n *\n * ### Typical usage\n * This utility is helpful when you need to:\n * - Parse stringified boolean flags (`'true'`, `'false'`)\n * - Validate configuration or query params\n * - Handle environment variables (`process.env.FEATURE_ENABLED`)\n *\n * ### Type narrowing\n * When this function returns `true`, TypeScript infers:\n * ```ts\n * value is string\n * ```\n * and you can safely pass it to a boolean converter (e.g. `formatToBool()`).\n *\n * ### Performance\n * - Time complexity: **O(1)**  \n * - Space complexity: **O(1)**\n *\n * ### Examples\n *\n * @example\n * // Valid boolean strings\n * isStrBool('true');        // => true\n * isStrBool('FALSE');       // => true\n * isStrBool(' True ');      // => true\n *\n * @example\n * // Invalid strings\n * isStrBool('yes');         // => false\n * isStrBool('0');           // => false\n * isStrBool('');            // => false\n *\n * @example\n * // Non-string inputs\n * isStrBool(true);          // => false\n * isStrBool(1);             // => false\n * isStrBool(null);          // => false\n *\n * @example\n * // Combined with formatToBool()\n * import { formatToBool } from '../bool/formatToBool';\n *\n * const val: unknown = 'False';\n * if (isStrBool(val)) {\n *   console.log(formatToBool(val)); // false\n * }\n *\n * @see isStr\n * @see isStrFilled\n * @see isBool\n * @see formatToBool\n *\n * @category Validation\n * @public\n * @since 2.0.0\n */\nexport function isStrBool(value: unknown): value is string {\n\tif (!isStrFilled(value)) {\n\t\treturn false;\n\t}\n\tconst normalized = value.trim().toLowerCase();\n\t\n\treturn normalized === 'true' || normalized === 'false';\n}\n","import { isStr } from '../index';\n\n/**\n * Checks whether a given value is a **non-empty string** (not just whitespace).\n *\n * @summary\n * A strict type guard that returns `true` only if the value is a string\n * containing at least one non-whitespace character.  \n * This is an extended form of {@link isStr} that excludes empty (`\"\"`) and\n * whitespace-only strings (`\"   \"`).\n *\n * @param value - Any value to test.\n *\n * @returns `true` if the value is a string with visible content, otherwise `false`.\n *\n * @remarks\n * ### Behavior\n * - Uses {@link isStr} to confirm the value is a string primitive.\n * - Calls `.trim()` to remove whitespace and checks if the resulting length is greater than zero.\n * - Returns `false` for:\n *   - Empty strings (`\"\"`)\n *   - Whitespace-only strings (`\"   \"`, `\"\\n\"`, `\"\\t\"`)\n *   - Non-string values (`number`, `boolean`, `object`, `null`, etc.)\n *\n * ### Comparison\n * | Function        | Description                       | Example                   |\n * |-----------------|-----------------------------------|---------------------------|\n * | `isStr`         | Any string (including empty)      | `\"\"` true                 |\n * | `isStrFilled`   | Non-empty trimmed string only     | `\"  \"` false / `\"x\"` true |\n *\n * ### Type narrowing\n * When this function returns `true`, TypeScript infers:\n * ```ts\n * value is string\n * ```\n * ensuring safe use of string operations.\n *\n * ### Performance\n * - Time complexity: **O(n)** (due to `.trim()`).\n * - Space complexity: **O(1)**.\n *\n * ### Examples\n *\n * @example\n * // Valid strings\n * isStrFilled('hello');     // => true\n * isStrFilled('  text  ');  // => true\n *\n * @example\n * // Empty or whitespace-only\n * isStrFilled('');          // => false\n * isStrFilled('   ');       // => false\n *\n * @example\n * // Non-string values\n * isStrFilled(null);        // => false\n * isStrFilled(123);         // => false\n * isStrFilled(undefined);   // => false\n *\n * @example\n * // Type narrowing\n * const val: unknown = '  value ';\n * if (isStrFilled(val)) {\n *   console.log(val.trim().toUpperCase()); // safe\n * }\n *\n * @see isStr\n * @see isArrFilled\n * @see isObjFilled\n *\n * @category Type Guards\n * @public\n * @since 2.0.0\n */\nexport function isStrFilled(value: unknown): value is string {\n\treturn isStr(value) && value.trim().length > 0;\n}\n","import { isStrFilled } from '../index';\n\n/**\n * Checks whether a given value is a string equal to **\"asc\"** or **\"desc\"** (case-insensitive).\n *\n * @summary\n * A strict type guard that validates sorting direction strings —  \n * `\"asc\"` (ascending) or `\"desc\"` (descending).  \n * Useful for validating API parameters, SQL sort directives, or UI sort controls.\n *\n * @param value - Any value to test.\n *\n * @returns `true` if the value is a non-empty string representing `\"asc\"` or `\"desc\"`, otherwise `false`.\n *\n * @remarks\n * ### Behavior\n * 1. Uses {@link isStrFilled} to ensure the value is a non-empty string.\n * 2. Trims whitespace and converts it to lowercase.\n * 3. Returns `true` only if the normalized value equals `\"asc\"` or `\"desc\"`.\n * 4. Returns `false` for empty strings, other words, or non-string types.\n *\n * ### Type narrowing\n * When this function returns `true`, TypeScript infers:\n * ```ts\n * value is 'asc' | 'desc'\n * ```\n * which is ideal for type-safe sort order handling in functions and APIs.\n *\n * ### Performance\n * - Time complexity: **O(1)** (fixed length checks)\n * - Space complexity: **O(1)**\n *\n * ### Examples\n *\n * @example\n * // Valid inputs\n * isStrAscDesc('asc');     // => true\n * isStrAscDesc('DESC');    // => true\n * isStrAscDesc(' Asc ');   // => true\n *\n * @example\n * // Invalid inputs\n * isStrAscDesc('ascending'); // => false\n * isStrAscDesc('');          // => false\n * isStrAscDesc(null);        // => false\n * isStrAscDesc('up');        // => false\n *\n * @example\n * // Type narrowing in use\n * function sortData(order: unknown) {\n *   if (isStrAscDesc(order)) {\n *     console.log(`Sorting in ${order} order`);\n *   } else {\n *     console.log('Invalid sort direction');\n *   }\n * }\n *\n * @see isStr\n * @see isStrFilled\n *\n * @category Validation\n * @public\n * @since 2.0.0\n */\nexport function isStrAscDesc(value: unknown): value is 'asc' | 'desc' {\n\tif (!isStrFilled(value)) {\n\t\treturn false;\n\t}\n\tconst normalized = value.trim().toLowerCase();\n\t\n\treturn normalized === 'asc' || normalized === 'desc';\n}\n","import { isStr } from '../index';\n\n/**\n * Checks whether a given value is a **valid variable-like identifier**.\n *\n * @summary\n * A strict type guard that returns `true` only if the value is a string\n * matching the pattern of a valid **programming variable name**:  \n * must start with a letter (`A–Z`, `a–z`) or underscore (`_`),\n * and may contain only letters, digits, or underscores afterward.\n *\n * @param value - Any value to test.\n *\n * @returns `true` if the value is a syntactically valid variable name; otherwise `false`.\n *\n * @remarks\n * ### Validation rule\n * Uses the following regular expression:\n * ```regex\n * /^[A-Za-z_][A-Za-z0-9_]*$/\n * ```\n * This enforces:\n * - **First character:** a Latin letter (`A–Z`, `a–z`) or underscore (`_`)\n * - **Subsequent characters:** any combination of letters, digits, or underscores\n * - **No spaces, symbols, or Unicode letters** are allowed\n *\n * ### Typical use cases\n * - Validating variable names in configuration files or templates\n * - Checking safe property keys for code generation\n * - Ensuring identifiers in scripting or parsing logic\n *\n * ### Behavior\n * - Returns `false` for:\n *   - Strings starting with digits (`\"1abc\"`)\n *   - Strings containing hyphens or spaces (`\"my-var\"`, `\"user name\"`)\n *   - Empty strings or non-string values\n * - Returns `true` for:\n *   - `\"name\"`, `\"_value\"`, `\"myVar1\"`, `\"SOME_CONSTANT\"`\n *\n * ### Type narrowing\n * When this function returns `true`, TypeScript infers:\n * ```ts\n * value is string\n * ```\n * ensuring safe string usage in contexts like symbol tables or identifier maps.\n *\n * ### Performance\n * - Time complexity: **O(n)** — proportional to string length (regex evaluation)\n * - Space complexity: **O(1)**\n *\n * ### Examples\n *\n * @example\n * // Valid identifiers\n * isVar('name');          // => true\n * isVar('_id');           // => true\n * isVar('myVar1');        // => true\n * isVar('SOME_CONSTANT'); // => true\n *\n * @example\n * // Invalid identifiers\n * isVar('');              // => false\n * isVar('1var');          // => false\n * isVar('user-name');     // => false\n * isVar('my var');        // => false\n * isVar('$value');        // => false\n *\n * @example\n * // Non-string values\n * isVar(null);            // => false\n * isVar(123);             // => false\n * isVar({});              // => false\n *\n * @see isStr\n * @see isStrFilled\n *\n * @category Validation\n * @public\n * @since 2.0.0\n */\nexport function isVar(value: unknown): value is string {\n\treturn isStr(value) && /^[A-Za-z_][A-Za-z0-9_]*$/.test(value);\n}\n","import type { JSONLike } from '../index';\nimport { tryParseJSON } from '../index';\n\n/**\n * Matches strings surrounded by a single, double, or backtick quote.\n *\n * @example\n * ```ts\n * QUOTED_RE.test(`\"hello\"`); // true\n * QUOTED_RE.test(`'world'`); // true\n * QUOTED_RE.test('`foo`');   // true\n * QUOTED_RE.test('bar');     // false\n * ```\n *\n * @internal\n */\nconst QUOTED_RE = /^(['\"`])([\\s\\S]*)\\1$/;\n\n/**\n * Parses a string that may represent JSON, quoted scalars, or plain text.\n *\n * @remarks\n * The parsing order is:\n *\n * 1. Try JSON via {@link tryParseJSON}. If it works, return the parsed value.\n * 2. If not JSON, check if the string is quoted with `'`, `\"` or `` ` ``.\n *    If quoted, return the **unquoted** inner text.\n * 3. If not quoted:\n *    - If `allowString === true`, return the **trimmed** string as-is.\n *    - Otherwise return `null`.\n *\n * This helper is used recursively by {@link jsonDecode} to decode string fields\n * found inside arrays/objects.\n *\n * @param s - Source string.\n * @param allowString - Whether to allow returning raw (unquoted) strings.\n * @returns A JSON-like value, or `null` if the string cannot be interpreted\n *          and `allowString` is `false`.\n *\n * @example\n * ```ts\n * parseStringLike('{\"a\":1}', false); // -> { a: 1 }\n * parseStringLike('\"hello\"', false); // -> \"hello\"\n * parseStringLike('hello', false);   // -> null\n * parseStringLike('hello', true);    // -> \"hello\"\n * ```\n *\n * @internal\n */\nexport function parseStringLike(s: string, allowString: boolean): JSONLike | null {\n\tconst trimmed = s.trim();\n\tconst pr = tryParseJSON(trimmed);\n\t\n\tif (pr.ok) {\n\t\treturn pr.value;\n\t}\n\tconst m = QUOTED_RE.exec(trimmed);\n\t\n\tif (m) {\n\t\treturn m[2] as JSONLike;\n\t}\n\treturn allowString ? (trimmed as JSONLike) : null;\n}","import type { JSONLike } from '../index';\n\n/**\n * Attempts to parse a string using native {@link JSON.parse}.\n *\n * @remarks\n * Returns a discriminated union with `{ ok: true, value }` on success,\n * or `{ ok: false }` on any parsing error. Exceptions are caught and\n * **never thrown** to callers.\n *\n * @param str - The candidate JSON string.\n * @returns A result object indicating parse success/failure.\n *\n * @example\n * ```ts\n * tryParseJSON('{\"a\":1}'); // { ok: true, value: { a: 1 } }\n * tryParseJSON('not json'); // { ok: false }\n * ```\n *\n * @internal\n */\nexport function tryParseJSON(str: string): { ok: true; value: JSONLike } | { ok: false } {\n\ttry {\n\t\treturn { ok: true, value: JSON.parse(str) as JSONLike };\n\t} \n\tcatch (err) {\n\t}\n\treturn { ok: false };\n}","import type { JSONLike } from '../index';\nimport { \n\tisArrFilled,\n\tisArr, \n\tisObjFilled,\n\tisObj,\n\tisStrFilled,\n\tisNum,\n\tisBool,\n\tjsonEncode,\n\tparseStringLike,\n} from '../index';\n\n/**\n * Best-effort decoder that normalizes unknown input into a JSON-like value.\n *\n * @remarks\n * `jsonDecode` accepts many shapes of input and produces a `JSONLike` (or `null`)\n * according to the following rules:\n *\n * - **Primitive passthrough**: `null`, numbers, and booleans are returned as-is.\n * - **Arrays/Objects (filled)**: for each string element/property, we attempt to decode\n *   it via {@link parseStringLike} (JSON → unquoted string → raw string if `allowString`).\n *   Non-string items are passed through unchanged (cast to `JSONLike`).\n * - **Arrays/Objects (empty)**: returned as-is (they’re valid JSON).\n * - **Standalone strings**: decoded via {@link parseStringLike}.\n * - **Other values**: return `null`.\n *\n * The function is **non-throwing**; any JSON parse errors are swallowed internally\n * and mapped to either unquoted/raw strings (depending on `allowString`) or `null`.\n * \n * - Uses native `JSON.parse` — safe for untrusted strings provided you do not eval the result.\n * - Does **not** perform schema validation; if you need strict shapes, validate after decoding.\n *\n * @typeParam T - Target type to cast the normalized result to.  \n * Defaults to `JSONLike`. Use with care — this is a **type cast**, not a runtime check.\n *\n * @param value - The unknown input to decode (can be primitives, arrays, objects, etc.).\n * @param allowString - If `true`, non-JSON, non-quoted strings are returned as trimmed strings.\n *                      If `false`, such strings decode to `null`.\n *\n * @returns The decoded value cast to `T`, or `null` when it cannot be decoded.\n *\n * @example\n * ```ts\n * // 1) Primitives pass through\n * jsonDecode(42);           // 42\n * jsonDecode(true);         // true\n * jsonDecode(null);         // null\n *\n * // 2) JSON string\n * jsonDecode('{\"a\":[1,\"2\"]}'); // { a: [1, \"2\"] }\n *\n * // 3) Quoted string\n * jsonDecode('\"hello\"'); // \"hello\"\n *\n * // 4) Raw string with allowString=false (default)\n * jsonDecode('hello');   // null\n *\n * // 5) Raw string with allowString=true\n * jsonDecode('hello', true); // \"hello\"\n *\n * // 6) Arrays/objects with string fields get per-field decoding\n * jsonDecode({ a: '{\"k\":1}', b: 'world' }, true);\n * // -> { a: { k: 1 }, b: \"world\" }\n * ```\n *\n * @throws Never throws; invalid inputs yield `null` or are passed through per rules above.\n *\n * @public\n * @category JSON\n * @since 2.0.0\n */\nexport function jsonDecode<T = JSONLike>(value: unknown, allowString = false): T | null {\n\tif (value === null || isNum(value) || isBool(value)) {\n\t\treturn value as unknown as T;\n\t}\n\tif (isArrFilled(value)) {\n\t\tconst arr = value as ReadonlyArray<unknown>;\n\t\tconst out: JSONLike[] = [];\n\t\t\n\t\tfor (const item of arr) {\n\t\t\tif (isStrFilled(item)) {\n\t\t\t\tout.push(parseStringLike(String(item), allowString));\n\t\t\t}\n\t\t\telse {\n\t\t\t\tout.push(item as JSONLike);\n\t\t\t}\n\t\t}\n\t\treturn out as unknown as T;\n\t}\n\tif (isObjFilled(value)) {\n\t\tconst src = value as Record<string, unknown>;\n\t\tconst out: Record<string, JSONLike> = {};\n\t\t\n\t\tfor (const key of Object.keys(src)) {\n\t\t\tconst v = src[key];\n\t\t\t\n\t\t\tif (isStrFilled(v)) {\n\t\t\t\tout[key] = parseStringLike(String(v), allowString);\n\t\t\t} \n\t\t\telse {\n\t\t\t\tout[key] = v as JSONLike;\n\t\t\t}\n\t\t}\n\t\treturn out as unknown as T;\n\t}\n\tif (isArr(value) || isObj(value)) {\n\t\treturn value as unknown as T;\n\t}\n\tif (isStrFilled(value)) {\n\t\treturn parseStringLike(String(value), allowString) as unknown as T;\n\t}\n\treturn null;\n}\n","import { \n\tisObj,\n\tisArr, \n\tjsonDecode,\n} from '../index';\n\n/**\n * Safely serializes a plain object or array into a JSON string.\n *\n * @remarks\n * This helper wraps {@link JSON.stringify} and adds two key safety features:\n *\n * 1. It only serializes **objects** and **arrays**, ignoring all other data types\n *    (numbers, strings, booleans, `null`, `undefined`).\n * 2. It catches all potential `JSON.stringify` errors (such as circular references)\n *    and returns an empty string `\"\"` instead of throwing.\n *\n * The function is thus ideal for safe logging, diagnostics, or best-effort\n * serialization where throwing is undesirable.\n * \n * - The output is always a valid JSON string (or empty string on failure).\n * - Use {@link jsonDecode} to reverse the process and safely parse it back.\n * - BigInt values are **not supported** by `JSON.stringify` — they will trigger\n *   a caught error, resulting in an empty string.\n *\n * @param value - Any value to encode. Only arrays or plain objects will be serialized;\n *                other types return an empty string.\n *\n * @returns The JSON-encoded string representation of the input,  \n * or an empty string (`\"\"`) if:\n * - The input is not an array or object.\n * - Serialization fails (e.g., circular reference or BigInt values).\n *\n * @example\n * ```ts\n * // Example 1: Basic usage\n * jsonEncode({ a: 1, b: true });\n * // -> '{\"a\":1,\"b\":true}'\n *\n * // Example 2: Arrays\n * jsonEncode([1, 2, 3]);\n * // -> '[1,2,3]'\n *\n * // Example 3: Non-serializable input\n * jsonEncode(123);        // -> ''\n * jsonEncode('hello');    // -> ''\n * jsonEncode(undefined);  // -> ''\n *\n * // Example 4: Circular reference\n * const obj: any = {};\n * obj.self = obj;\n * jsonEncode(obj); // -> '' (fails safely)\n * ```\n *\n * @throws Never throws — all exceptions from `JSON.stringify` are caught internally.\n *\n * @see {@link jsonDecode} — performs the inverse operation with safe parsing and normalization.\n * @see {@link JSON.stringify} — the native method used under the hood.\n *\n * @public\n * @category JSON\n * @since 2.0.0\n */\nexport function jsonEncode(value: unknown): string {\n\ttry {\n\t\treturn (isObj(value) || isArr(value)) ? JSON.stringify(value) : '';\n\t}\n\tcatch (err) {\n\t}\n\treturn '';\n}\n","import type { FixedDecimal } from '../index';\n\n/**\n * Adjusts the **scale** (i.e., number of fractional digits) of a {@link FixedDecimal}\n * by a given offset without altering its numeric meaning.\n *\n * @remarks\n * A `FixedDecimal` represents a decimal number as:\n * ```ts\n * { sign: 1 | -1, digitsInteger: bigint, scale: number }\n * ```\n * where `digitsInteger × 10^(-scale)` yields the real value.\n *\n * This helper changes the `scale` while keeping the numerical value consistent.\n * When `scaleDelta > 0`, the function *increases* the scale (adds more fractional\n * digits of precision) **without changing** `digitsInteger`.  \n * When `scaleDelta < 0`, it *reduces* the scale by multiplying `digitsInteger`\n * to preserve the same actual numeric value.\n * \n * O(1) time and space, except for the BigInt multiplication when `scaleDelta < 0`.\n *\n * @param value - The {@link FixedDecimal} to adjust.  \n * Should contain:\n * - `sign`: either `1` (positive) or `-1` (negative),\n * - `digitsInteger`: the integer form of all digits without a decimal point,\n * - `scale`: the number of fractional digits currently represented.\n *\n * @param scaleDelta - The number of fractional places to add or remove.\n * Positive values mean **increase precision** (more digits after the decimal point);\n * negative values mean **reduce precision**, scaling the integer part accordingly.\n *\n * @returns A new {@link FixedDecimal} with the adjusted `scale` and appropriately\n * modified `digitsInteger` if needed.\n *\n * @throws {RangeError} If the operation would cause an invalid scale\n * (e.g., non-integer `scaleDelta`), though `Math.trunc` is used to normalize inputs.\n *\n * @example\n * ```ts\n * const num: FixedDecimal = { sign: 1, digitsInteger: 12345n, scale: 2 };\n * // Represents 123.45\n *\n * // Increase scale by +2 → same numeric value but more fractional digits\n * const up = changeFixedDecimalScale(num, +2);\n * // up = { sign: 1, digitsInteger: 12345n, scale: 4 } → 1.2345 × 10^2 = 123.45\n *\n * // Decrease scale by -2 → multiply digitsInteger to preserve value\n * const down = changeFixedDecimalScale(num, -2);\n * // down = { sign: 1, digitsInteger: 1234500n, scale: 0 } → 1234500 × 10^0 = 123.45\n * ```\n *\n * @example\n * ```ts\n * // No change when delta = 0\n * const same = changeFixedDecimalScale(num, 0);\n * // same === { sign: 1, digitsInteger: 12345n, scale: 2 }\n * ```\n * \n * @since 2.0.0\n */\nexport function changeFixedDecimalScale(value: FixedDecimal, scaleDelta: number): FixedDecimal {\n\tconst delta = Math.trunc(scaleDelta);\n\n\tif (delta === 0) {\n\t\treturn { ...value };\n\t}\n\tif (delta > 0) {\n\t\treturn {\n\t\t\tsign: value.sign,\n\t\t\tdigitsInteger: value.digitsInteger,\n\t\t\tscale: value.scale + delta,\n\t\t};\n\t}\n\tconst multiplier = 10n ** BigInt(-delta);\n\t\n\treturn {\n\t\tsign: value.sign,\n\t\tdigitsInteger: value.digitsInteger * multiplier,\n\t\tscale: value.scale + delta,\n\t};\n}\n","import { isNumPZ } from '../index';\n\n/**\n * Converts a number expressed in normalized exponential/scientific notation\n * (e.g., `\"1.23e+5\"`, `\"4e-7\"`, `\"0009.500e2\"`) into its **sign**, **integer**,\n * and **fractional** parts as plain decimal digit strings — **without** any\n * decimal point or leading `+`/`-` characters.\n *\n * @remarks\n * - This function does **not** perform numeric arithmetic; instead it does a\n *   textual normalization that preserves all significant digits exactly.\n * - It accepts the `sign` separately so that callers can pre-parse signs from\n *   inputs like `\"-1.23e3\"` and pass `sign = -1` with `exponentialString = \"1.23e3\"`.\n *   (If you already have a positive string, pass `sign = 1`.)\n * - The function normalizes the coefficient and exponent first, then uses a\n *   single regex match to validate the shape:\n *   - Coefficient: `([0-9]+)(?:\\.([0-9]*))?`\n *   - Exponent: `e([+\\-]?[0-9]+)`\n * - Trailing zeros are added to the **integer** side for positive net exponents,\n *   while leading zeros are added to the **fractional** side for negative net exponents.\n * - All returned parts (`integerPart`, `fractionalPart`) contain only ASCII digits.\n *   The decimal point is **not** returned; you can re-insert it if needed by\n *   placing it between `integerPart` and `fractionalPart`.\n * \n * Time O(n) and space O(n), where n is the number of digits in the coefficient,\n * due to string concatenation and slicing.\n *\n * @param sign - The pre-parsed sign of the number: `1` for positive, `-1` for negative.\n * @param exponentialString - A string in exponential notation.\n *   Examples: `\"1e3\"`, `\"1.23e+5\"`, `\"4.560e-2\"`, `\"0009.500e2\"`.\n *   The function is case-insensitive for the `'e'` and tolerates leading zeros in the coefficient.\n *\n * @returns An object with three properties:\n * - `sign`: Echo of the input sign (`1` | `-1`).\n * - `integerPart`: All digits to the left of the decimal point after expansion.\n * - `fractionalPart`: All digits to the right of the decimal point after expansion.\n *\n * @throws {Error} If `exponentialString` cannot be parsed as scientific notation.\n *\n * @example\n * ```ts\n * // 1.23 × 10^5 = 123000\n * convertExponentialToParts(1, \"1.23e5\");\n * // => { sign: 1, integerPart: \"123000\", fractionalPart: \"\" }\n * ```\n *\n * @example\n * ```ts\n * // 4.5 × 10^-3 = 0.0045\n * convertExponentialToParts(1, \"4.5e-3\");\n * // => { sign: 1, integerPart: \"0\", fractionalPart: \"0045\" }\n * ```\n *\n * @example\n * ```ts\n * // -7.00e+0 = -7\n * convertExponentialToParts(-1, \"7.00e0\");\n * // => { sign: -1, integerPart: \"7\", fractionalPart: \"\" }\n * ```\n *\n * @example\n * ```ts\n * // Leading zeros in coefficient are handled; fractional length adjusts exponent\n * convertExponentialToParts(1, \"0009.500e2\"); // 9.500 × 10^2 = 950\n * // => { sign: 1, integerPart: \"950\", fractionalPart: \"\" }\n * ```\n *\n * @example\n * ```ts\n * // You can reconstruct a normalized decimal string yourself:\n * const { sign, integerPart, fractionalPart } = convertExponentialToParts(-1, \"1.234e-2\");\n * const signChar = sign < 0 ? \"-\" : \"\";\n * const plain = fractionalPart ? `${integerPart}.${fractionalPart}` : integerPart;\n * // plain == \"0.01234\"\n * const result = signChar + plain; // \"-0.01234\"\n * ```\n *\n * @see isNumPZ — utility used here to detect non-negative integers (exponent ≥ 0).\n *\n * @since 2.0.0\n */\nexport function convertExponentialToParts(\n\tsign: 1 | -1,\n\texponentialString: string\n): { sign: 1 | -1; integerPart: string; fractionalPart: string } {\n\tconst match = /^([0-9]+)(?:\\.([0-9]*))?e([+\\-]?[0-9]+)$/i.exec(\n\t\t(() => {\n\t\t\tconst [coefficient, exponentText] = exponentialString.split(/e/i);\n\t\t\tconst [integerPart, fractionalPart = ''] = coefficient.split('.');\n\t\t\tconst allDigits = integerPart.replace(/^0+/, '') + fractionalPart;\n\t\t\tconst exponentValue = parseInt(exponentText, 10) - fractionalPart.length;\n\t\t\t\n\t\t\treturn `${allDigits || '0'}e${exponentValue}`;\n\t\t})()\n\t);\n\n\tif (!match) {\n\t\tthrow new Error('Failed to parse exponential notation.');\n\t}\n\tlet allDigits = match[1];\n\tconst exponent = parseInt(match[3], 10);\n\n\tif (isNumPZ(exponent)) {\n\t\tallDigits = allDigits + '0'.repeat(exponent);\n\t\t\n\t\treturn { \n\t\t\tsign, \n\t\t\tintegerPart: allDigits || '0', \n\t\t\tfractionalPart: '', \n\t\t};\n\t} \n\telse {\n\t\tconst digitsToLeft = -exponent;\n\t\t\n\t\tif (digitsToLeft >= allDigits.length) {\n\t\t\tconst missingZeros = '0'.repeat(digitsToLeft - allDigits.length);\n\t\t\t\n\t\t\treturn {\n\t\t\t\tsign,\n\t\t\t\tintegerPart: '0',\n\t\t\t\tfractionalPart: missingZeros + allDigits,\n\t\t\t};\n\t\t}\n\t\telse {\n\t\t\tconst splitIndex = allDigits.length - digitsToLeft;\n\t\t\t\n\t\t\treturn {\n\t\t\t\tsign,\n\t\t\t\tintegerPart: allDigits.slice(0, splitIndex),\n\t\t\t\tfractionalPart: allDigits.slice(splitIndex),\n\t\t\t};\n\t\t}\n\t}\n}","import type { FixedDecimal } from '../index';\nimport { fixedDecimalToStr } from '../index';\n\n/**\n * Converts a {@link FixedDecimal} — an exact decimal representation —\n * into a native JavaScript `number` (IEEE 754 double precision).\n *\n * @remarks\n * This function is a **lossy** conversion when `value` contains\n * more precision than JavaScript’s floating-point format can represent.\n * It internally calls {@link fixedDecimalToStr} to produce a normalized\n * string such as `\"-123.4567\"` and then passes it to the built-in\n * `Number()` constructor.\n * \n * O(n) relative to the number of digits in `digitsInteger`\n * (due to string creation in {@link fixedDecimalToStr}).\n *\n * @param value - The {@link FixedDecimal} instance to convert.\n * Must contain:\n * - `sign`: either `1` or `-1`;\n * - `digitsInteger`: a `bigint` representing all digits without any decimal point;\n * - `scale`: how many digits belong after the decimal point.\n *\n * @returns The approximate numeric value as a JavaScript `number`.\n * If the string form is too large or too precise, the result may be\n * rounded or become `Infinity`.\n *\n * @example\n * ```ts\n * const fd: FixedDecimal = { sign: 1, digitsInteger: 12345n, scale: 2 };\n * // Represents exactly 123.45\n * const num = fixedDecimalToNum(fd); // 123.45 (Number)\n * ```\n *\n * @example\n * ```ts\n * // Handles negative numbers as well\n * const neg: FixedDecimal = { sign: -1, digitsInteger: 987n, scale: 3 };\n * const n = fixedDecimalToNum(neg); // -0.987\n * ```\n *\n * @example\n * ```ts\n * // Extreme precision may lose digits beyond ~15–17 significant figures\n * const big: FixedDecimal = { sign: 1, digitsInteger: 12345678901234567890n, scale: 10 };\n * const approx = fixedDecimalToNum(big);\n * console.log(approx); // ~1234567890.1234567  (rounded)\n * ```\n *\n * @see fixedDecimalToStr — for the exact string representation\n * @see https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number#precision JavaScript number precision\n *\n * @since 2.0.0\n */\nexport function fixedDecimalToNum(value: FixedDecimal): number {\n\treturn Number(fixedDecimalToStr(value));\n}\n","import type { FixedDecimal } from '../index';\n\n/**\n * Converts a {@link FixedDecimal} — an exact, integer-based decimal structure —\n * into its canonical string representation (e.g. `\"-123.456\"`).\n *\n * @remarks\n * This function is **exact and reversible**: no precision loss occurs because it\n * operates on the raw digit string (`digitsInteger`) and inserts the decimal point\n * purely by string manipulation.\n *\n * The algorithm:\n * 1. Converts the `digitsInteger` `BigInt` to a string of digits.\n * 2. If `scale` is `0`, returns the signed integer directly.\n * 3. If `scale` is positive:\n *    - Pads with leading zeros when the number of digits is smaller than `scale`.\n *    - Otherwise, splits at the appropriate boundary between integer and fractional parts.\n * \n * O(n) where `n` is the number of digits in `digitsInteger.toString()`.\n *\n * @param value - The {@link FixedDecimal} object:\n *   - `sign`: `1` for positive or `-1` for negative numbers.\n *   - `digitsInteger`: All digits as a `BigInt` without a decimal point.\n *   - `scale`: The number of digits after the decimal point.\n *\n * @returns A string representation of the number, including a `-` sign if negative.\n * If the number is fractional, a single `.` separates integer and fractional parts.\n *\n * @example\n * ```ts\n * const fd: FixedDecimal = { sign: 1, digitsInteger: 12345n, scale: 2 };\n * fixedDecimalToStr(fd); // \"123.45\"\n * ```\n *\n * @example\n * ```ts\n * // Negative number\n * const neg: FixedDecimal = { sign: -1, digitsInteger: 987n, scale: 3 };\n * fixedDecimalToStr(neg); // \"-0.987\"\n * ```\n *\n * @example\n * ```ts\n * // Small fractional with fewer digits than scale\n * const tiny: FixedDecimal = { sign: 1, digitsInteger: 12n, scale: 5 };\n * fixedDecimalToStr(tiny); // \"0.00012\"\n * ```\n *\n * @example\n * ```ts\n * // Whole number (scale = 0)\n * const whole: FixedDecimal = { sign: 1, digitsInteger: 42n, scale: 0 };\n * fixedDecimalToStr(whole); // \"42\"\n * ```\n *\n * @see changeFixedDecimalScale — for adjusting the scale value safely\n * @see fixedDecimalToNum — for converting to a JavaScript number\n *\n * @since 2.0.0\n */\nexport function fixedDecimalToStr(value: FixedDecimal): string {\n\tconst signSymbol = value.sign < 0 ? '-' : '';\n\tconst allDigitsString = value.digitsInteger.toString();\n\n\tif (value.scale === 0) {\n\t\treturn signSymbol + allDigitsString;\n\t}\n\tconst padZeros = value.scale - allDigitsString.length;\n\n\tif (padZeros >= 0) {\n\t\treturn signSymbol + '0.' + '0'.repeat(padZeros) + allDigitsString;\n\t}\n\tconst integerBoundary = allDigitsString.length - value.scale;\n\tconst integerText = allDigitsString.slice(0, integerBoundary);\n\tconst fractionalText = allDigitsString.slice(integerBoundary);\n\n\treturn signSymbol + integerText + '.' + fractionalText;\n}\n","import { \n\tfixedDecimalToNum,\n\tparseToFixedDecimal,\n\troundFixedDecimal, \n} from '../index';\n\n/**\n * Converts an arbitrary numeric input to a JavaScript `number`, optionally rounding\n * it to a fixed number of fractional digits using **half-up** rounding.\n *\n * @remarks\n * This function is a convenience wrapper around your fixed-precision helpers:\n *\n * 1. {@link parseToFixedDecimal} — parses the unknown input (`number`/`string`/etc.)\n *    into an exact, lossless fixed-decimal representation.\n * 2. `roundFixedDecimal` — (invoked only when `round > 1`) rounds that fixed-decimal\n *    value to the requested scale using the **half-up** algorithm.\n * 3. {@link fixedDecimalToNum} — converts the (optionally rounded) fixed-decimal\n *    back to a JavaScript `number`.\n *\n * Because rounding is done in fixed-precision space, you avoid common IEEE-754\n * floating-point artifacts (e.g., `0.1 + 0.2 !== 0.3`) during parsing/rounding.\n * Precision is finally limited only at the last step when the value is converted\n * to a JS `number`.\n *\n * @param value - Any value that represents a number. Typical cases:\n * - `number` (e.g., `12`, `-0.034`, `1e6`)\n * - numeric `string` (e.g., `\"42\"`, `\"-123.456\"`)\n * - values that your {@link parseToFixedDecimal} knows how to normalize.\n *\n * If the value cannot be parsed by {@link parseToFixedDecimal}, an error will be thrown from there.\n *\n * @param round - Target number of fractional digits for rounding **in fixed-precision**.\n * - If `round > 1`, the function rounds to exactly `round` digits after the decimal point\n *   using **half-up** (i.e., `.5` rounds away from zero) via `roundFixedDecimal`.\n * - If `round <= 1`, no rounding is applied; the parsed value is passed through as-is.\n *\n * @defaultValue `1` (no rounding; passthrough)\n *\n * @returns The resulting numeric value as a JavaScript `number`.\n *\n * @throws {Error}\n * - Re-throws any parsing/normalization errors from {@link parseToFixedDecimal}.\n * - Re-throws any rounding errors from `roundFixedDecimal` (e.g., invalid scale).\n *\n * @example\n * // No rounding (default `round = 1` → passthrough)\n * formatToNum(\"123.456\");         // => 123.456\n * formatToNum(0.034);             // => 0.034\n *\n * @example\n * // Round to 2 fractional digits (half-up)\n * formatToNum(\"123.456\", 2);      // => 123.46  (because .456 → .46)\n * formatToNum(\"-1.235\", 2);       // => -1.24   (half-up away from zero)\n *\n * @example\n * // Large values: parsed and rounded in fixed precision, then converted to number\n * formatToNum(\"234893249238948.000003432\", 6); // precise rounding in fixed space,\n *                                              // final result as JS number\n *\n * @example\n * // Explicit passthrough (any `round <= 1` behaves the same)\n * formatToNum(\"1000.555\", 1);     // => 1000.555 (no rounding step invoked)\n * formatToNum(\"1000.555\", 0);     // => 1000.555 (still no rounding)\n *\n * @see parseToFixedDecimal\n * @see fixedDecimalToNum\n * @see roundFixedDecimal\n *\n * @category Number Formatting\n * @since 2.0.0\n * @public\n */\nexport function formatToNum(value: unknown, round: number = 1, throwError: boolean = false): number {\n\ttry {\n\t\treturn fixedDecimalToNum((round > 1) ? roundFixedDecimal(parseToFixedDecimal(value), round, 'half-up') : parseToFixedDecimal(value));\n\t}\n\tcatch (err: any) {\n\t\tif (throwError) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\treturn 0;\n}\n","import { convertExponentialToParts } from '../index';\n\n/**\n * Normalizes an arbitrary numeric input into sign, integer, and fractional string parts\n * without losing precision, preparing it for exact fixed-decimal processing.\n *\n * @remarks\n * This utility accepts `bigint`, `number`, and `string` inputs and returns a tuple-like\n * object with three fields:\n *\n * - `sign`: `1` for non-negative values, `-1` for negative values.\n * - `integerPart`: the digits before the decimal point as a string (no sign, no separators).\n * - `fractionalPart`: the digits after the decimal point as a string (no sign, no separators).\n *\n * For JavaScript `number`s, the function first checks finiteness and then converts the\n * absolute value to an exponential string (via `toExponential(30)`) to avoid\n * floating-point artifacts when extracting digits. It delegates parsing of that exponential\n * form to {@link convertExponentialToParts}.\n *\n * For `string`s, the function:\n * - Trims whitespace and replaces a comma `,` decimal separator with a dot `.`.\n * - Parses and removes a leading `+`/`-` sign (if present).\n * - Validates the remaining characters with a permissive numeric pattern that allows:\n *   - optional integer digits,\n *   - an optional decimal point with digits,\n *   - an optional scientific exponent (`e` or `E` with optional `+`/`-` and digits).\n * - If an exponent is present, it delegates to {@link convertExponentialToParts};\n *   otherwise it splits on the decimal point.\n *\n * **Important:** This function does not strip leading zeros in `integerPart` or trailing\n * zeros in `fractionalPart`. If you need canonicalized output (e.g., remove leading/trailing\n * zeros), do that in a later step (e.g., when building your fixed-decimal representation).\n *\n * @param input - The numeric input to normalize. Supported types:\n * - `bigint` (e.g., `123n`, `-9007199254740993n`)\n * - `number` (finite only; `NaN`, `Infinity`, `-Infinity` will throw)\n * - `string` (e.g., `\"42\"`, `\"-0.034\"`, `\"1.2e-5\"`, with optional leading sign, optional\n *   decimal part, optional exponent; commas are allowed as decimal separators and are\n *   converted to dots)\n *\n * @returns An object with the normalized components:\n * ```ts\n * {\n *   sign: 1 | -1;\n *   integerPart: string;\n *   fractionalPart: string;\n * }\n * ```\n * The `integerPart` and `fractionalPart` contain only ASCII digits (`0`–`9`) and\n * **never** include sign or exponent markers.\n *\n * @throws {Error}\n * - If `input` is a `number` but not finite (`NaN`, `Infinity`, `-Infinity`).\n * - If `input` is a `string` that is empty after trimming/replacement.\n * - If `input` is a `string` that fails the numeric validation regex.\n * - If `input` is of an unsupported type (not `bigint`, `number`, or `string`).\n * - Any errors propagated from {@link convertExponentialToParts} when parsing exponential forms.\n *\n * @example\n * // bigint input → fractional part is empty\n * normalizeToDecimalComponents(123n);\n * // => { sign: 1, integerPart: \"123\", fractionalPart: \"\" }\n *\n * @example\n * // negative bigint\n * normalizeToDecimalComponents(-987654321n);\n * // => { sign: -1, integerPart: \"987654321\", fractionalPart: \"\" }\n *\n * @example\n * // finite number input; uses exponential internally to avoid FP artifacts\n * normalizeToDecimalComponents(0.0000034);\n * // => { sign: 1, integerPart: \"0\", fractionalPart: \"0000034\" }  // exact digits\n *\n * @example\n * // string with decimal comma and explicit sign\n * normalizeToDecimalComponents(\"+1,250\");\n * // => { sign: 1, integerPart: \"1\", fractionalPart: \"250\" }\n *\n * @example\n * // scientific notation string\n * normalizeToDecimalComponents(\"-1.234e+3\");\n * // => { sign: -1, integerPart: \"1234\", fractionalPart: \"\" }\n *\n * @example\n * // invalid string (throws)\n * normalizeToDecimalComponents(\"12.34.56\"); // Error: Invalid numeric string.\n *\n * @see convertExponentialToParts\n * @category Parsing\n * @since 2.0.0\n * @public\n */\nexport function normalizeToDecimalComponents(input: unknown): {\n\tsign: 1 | -1;\n\tintegerPart: string;\n\tfractionalPart: string;\n} {\n\tif (typeof input === 'bigint') {\n\t\tconst sign: 1 | -1 = input < 0n ? -1 : 1;\n\t\tconst absoluteValue = (input < 0n ? -input : input).toString();\n\t\t\n\t\treturn { \n\t\t\tsign, \n\t\t\tintegerPart: absoluteValue, \n\t\t\tfractionalPart: '', \n\t\t};\n\t}\n\tif (typeof input === 'number') {\n\t\tif (!Number.isFinite(input)) {\n\t\t\tthrow new Error('Input number is not finite.');\n\t\t}\n\t\tconst sign: 1 | -1 = input < 0 ? -1 : 1;\n\t\tconst absoluteValue = Math.abs(input);\n\t\tconst exponentialForm = absoluteValue.toExponential(30); // например \"1.23456e-5\"\n\t\t\n\t\treturn convertExponentialToParts(sign, exponentialForm);\n\t}\n\tif (typeof input === 'string') {\n\t\tlet processed = input.trim().replace(',', '.');\n\t\t\n\t\tif (!processed) {\n\t\t\tthrow new Error('Input string is empty.');\n\t\t}\n\t\tlet sign: 1 | -1 = 1;\n\t\t\n\t\tif (processed.startsWith('+') || processed.startsWith('-')) {\n\t\t\tsign = processed.startsWith('-') ? -1 : 1;\n\t\t\tprocessed = processed.slice(1);\n\t\t}\n\t\tif (/^[0-9]*\\.?[0-9]*(e[+\\-]?[0-9]+)?$/i.test(processed)) {\n\t\t\tif (/e/i.test(processed)) {\n\t\t\t\treturn convertExponentialToParts(sign, processed);\n\t\t\t}\n\t\t\tconst [ integerPart = '0', fractionalPart = '' ] = processed.split('.');\n\t\t\t\n\t\t\treturn { \n\t\t\t\tsign, \n\t\t\t\tintegerPart, \n\t\t\t\tfractionalPart, \n\t\t\t};\n\t\t}\n\t\tthrow new Error('Invalid numeric string.');\n\t}\n\tthrow new Error('Unsupported input type.');\n}","import type { FixedDecimal } from '../index';\nimport { normalizeToDecimalComponents } from '../index';\n\n/**\n * Parses any numeric input (`number`, `bigint`, or `string`) into an exact {@link FixedDecimal}\n * representation, preserving all digits without floating-point rounding errors.\n *\n * @remarks\n * This function transforms arbitrary numeric input into a **fixed-precision decimal structure**\n * that can safely represent extremely large or small values without losing information.\n * It achieves this by first decomposing the input using {@link normalizeToDecimalComponents}\n * and then constructing a `FixedDecimal` object consisting of:\n *\n * - `sign` → `1` for positive values, `-1` for negative values.\n * - `digitsInteger` → a `BigInt` that encodes *all digits* of the number as if\n *   the decimal point were removed.\n * - `scale` → the count of digits that were originally after the decimal point.\n *\n * The resulting value can later be precisely converted back to a string or to a\n * JavaScript `number` using helpers like `fixedDecimalToStr` or `fixedDecimalToNum`.\n *\n * This process **avoids IEEE-754 floating-point artifacts**, ensuring mathematically\n * exact handling of decimal fractions (e.g. `\"0.1\" + \"0.2\" → 0.3` instead of `0.30000000000000004`).\n *\n * @param input - Any numeric source value. Supported types:\n * - `number` — finite only (`NaN`, `Infinity`, `-Infinity` will throw).\n * - `bigint` — directly converted without fractional digits.\n * - `string` — may contain optional sign, decimal point, or exponential notation (`1.23e-5`).\n *   Commas `,` as decimal separators are also supported and converted to dots `.`.\n *\n * @returns A normalized {@link FixedDecimal} object:\n * ```ts\n * {\n *   sign: 1 | -1;           // the numeric sign\n *   digitsInteger: bigint;   // all digits as a BigInt, no decimal point\n *   scale: number;           // number of digits after the decimal\n * }\n * ```\n *\n * @throws {Error}\n * - If the input is not a supported type (`number`, `bigint`, or `string`).\n * - If the string cannot be parsed as a valid numeric representation.\n * - If the number is not finite.\n * - Any error propagated from {@link normalizeToDecimalComponents}.\n *\n * @example\n * // Simple integer number\n * parseToFixedDecimal(42);\n * // => { sign: 1, digitsInteger: 42n, scale: 0 }\n *\n * @example\n * // Decimal fraction\n * parseToFixedDecimal(\"123.456\");\n * // => { sign: 1, digitsInteger: 123456n, scale: 3 }\n *\n * @example\n * // Number in exponential notation\n * parseToFixedDecimal(\"-1.23e-4\");\n * // => { sign: -1, digitsInteger: 123n, scale: 6 } // represents -0.000123\n *\n * @example\n * // Leading zeros and trailing fractional zeros are trimmed internally\n * parseToFixedDecimal(\"00045.67000\");\n * // => { sign: 1, digitsInteger: 4567n, scale: 2 } // \"45.67\"\n *\n * @example\n * // Very large integer input using bigint\n * parseToFixedDecimal(123456789012345678901234567890n);\n * // => { sign: 1, digitsInteger: 123456789012345678901234567890n, scale: 0 }\n *\n * @example\n * // Negative value with high precision fraction\n * parseToFixedDecimal(\"-0.00000003432\");\n * // => { sign: -1, digitsInteger: 3432n, scale: 11 }\n *\n * @see normalizeToDecimalComponents\n * @see FixedDecimal\n * @see fixedDecimalToNum\n * @see fixedDecimalToStr\n *\n * @category Parsing\n * @since 2.0.0\n * @public\n */\nexport function parseToFixedDecimal(input: unknown): FixedDecimal {\n\tconst { \n\t\tsign, \n\t\tintegerPart, \n\t\tfractionalPart, \n\t} = normalizeToDecimalComponents(input);\n\tconst integerDigits = integerPart.replace(/^0+/, '') || '0';\n\tconst fractionalDigits = fractionalPart.replace(/0+$/, '');\n\tconst combinedDigits = (integerDigits + fractionalDigits) || '0';\n\n\treturn {\n\t\tsign,\n\t\tdigitsInteger: BigInt(combinedDigits),\n\t\tscale: fractionalDigits.length,\n\t};\n}\n","import type { FixedDecimal } from '../index';\n\n/**\n * Rounds a {@link FixedDecimal} value to the specified number of fractional digits,\n * using either **half-up** (standard rounding) or **truncation** (cut-off without rounding).\n *\n * @remarks\n * This function operates entirely in fixed-precision integer space (`BigInt` arithmetic),\n * so rounding is mathematically exact — it never suffers from floating-point errors.\n *\n * Internally, it determines how many fractional digits must be removed from\n * `source.digitsInteger` to reach the desired precision (`decimalPlaces`), divides\n * by `10 ** digitsToRemove`, and conditionally increments the result depending on\n * the remainder and rounding mode.\n *\n * It preserves the original `sign` and returns a new {@link FixedDecimal} object\n * with an updated `scale` (number of digits after the decimal point).\n *\n * ---\n * **Rounding modes:**\n * - `'half-up'` — standard rounding to nearest neighbor; `.5` rounds **away from zero**.\n *   Example: `1.235 → 1.24`, `-1.235 → -1.24`.\n * - `'trunc'` — truncates digits beyond the target precision (rounds **toward zero**).\n *   Example: `1.239 → 1.23`, `-1.239 → -1.23`.\n *\n * ---\n * @param source - The input {@link FixedDecimal} to round.\n * Must contain a valid combination of:\n * - `sign`: `1` or `-1`\n * - `digitsInteger`: a `BigInt` representing all digits (no decimal point)\n * - `scale`: number of digits after the decimal\n *\n * @param decimalPlaces - Target number of digits to keep **after the decimal point**.\n * Values less than 0 are treated as 0.  \n * For example, rounding to `2` means \"keep two digits after the decimal\".\n *\n * @param roundMode - Rounding algorithm to use:\n * - `'half-up'` (default) → rounds 0.5 and higher up.\n * - `'trunc'` → simply removes extra digits without rounding up.\n *\n * @defaultValue `'half-up'`\n *\n * @returns A **new** {@link FixedDecimal} with the adjusted `digitsInteger`\n * and `scale` equal to `decimalPlaces`.  \n * If the requested precision is greater than or equal to `source.scale`,\n * the source value is returned unchanged (shallow copy).\n *\n * @throws {Error}\n * - Never throws directly in normal use, but may propagate errors if invalid\n *   numeric parameters are passed (e.g., non-integer `decimalPlaces`).\n *\n * ---\n * @example\n * // Half-up rounding\n * const value: FixedDecimal = { sign: 1, digitsInteger: 123456n, scale: 3 }; // 123.456\n * roundFixedDecimal(value, 2, 'half-up');\n * // => { sign: 1, digitsInteger: 12346n, scale: 2 }  // 123.46\n *\n * @example\n * // Truncation (cut-off)\n * const value: FixedDecimal = { sign: 1, digitsInteger: 123456n, scale: 3 };\n * roundFixedDecimal(value, 2, 'trunc');\n * // => { sign: 1, digitsInteger: 12345n, scale: 2 }  // 123.45\n *\n * @example\n * // No rounding needed (scale already smaller)\n * const v: FixedDecimal = { sign: -1, digitsInteger: 1234n, scale: 1 }; // -123.4\n * roundFixedDecimal(v, 3);\n * // => identical copy: { sign: -1, digitsInteger: 1234n, scale: 1 }\n *\n * @example\n * // Rounding very small values\n * const v: FixedDecimal = { sign: 1, digitsInteger: 123n, scale: 6 }; // 0.000123\n * roundFixedDecimal(v, 4);\n * // => { sign: 1, digitsInteger: 1n, scale: 4 }  // 0.0001\n *\n * @example\n * // Rounding negative numbers (half-up → away from zero)\n * const v: FixedDecimal = { sign: -1, digitsInteger: 125n, scale: 2 }; // -1.25\n * roundFixedDecimal(v, 1, 'half-up');\n * // => { sign: -1, digitsInteger: 13n, scale: 1 }  // -1.3\n *\n * @see FixedDecimal\n * @see parseToFixedDecimal\n * @see fixedDecimalToNum\n * @see fixedDecimalToStr\n * @see formatToNum\n *\n * @category Math\n * @since 2.0.0\n * @public\n */\nexport function roundFixedDecimal(\n\tsource: FixedDecimal,\n\tdecimalPlaces: number,\n\troundMode: 'half-up' | 'trunc' = 'half-up'\n): FixedDecimal {\n\tconst targetPrecision = Math.max(0, Math.trunc(decimalPlaces));\n\n\tif (source.scale <= targetPrecision) {\n\t\treturn { ...source };\n\t}\n\tconst digitsToRemove = source.scale - targetPrecision;\n\tconst divisionFactor = 10n ** BigInt(digitsToRemove);\n\tconst integerPart = source.digitsInteger / divisionFactor;\n\tconst remainder = source.digitsInteger % divisionFactor;\n\n\tif (roundMode === 'trunc' || remainder === 0n) {\n\t\treturn { \n\t\t\tsign: source.sign, \n\t\t\tdigitsInteger: integerPart, \n\t\t\tscale: targetPrecision, \n\t\t};\n\t}\n\tconst halfThreshold = divisionFactor / 2n;\n\tconst shouldRoundUp = remainder >= halfThreshold;\n\tconst roundedValue = shouldRoundUp ? integerPart + 1n : integerPart;\n\t\n\treturn { \n\t\tsign: source.sign, \n\t\tdigitsInteger: roundedValue, \n\t\tscale: targetPrecision, \n\t};\n}","import { \n\tisStrFilled,\n\tisStr,\n\tformatToTrim, \n} from '../index';\n\n/**\n * Converts any given string-like value into a lower-cased, trimmed string.\n *\n * @summary\n * Safely transforms an unknown value into a normalized lowercase string.\n * If the input is not a valid non-empty string, the function returns an empty string (`\"\"`).\n *\n * @param value - Any unknown input to convert to lowercase.\n *\n * @returns A lowercase string, or an empty string if the input is not a valid string.\n *\n * @remarks\n * ### Processing steps\n * 1. **Type check** — ensures the input is a string using {@link isStr}.\n * 2. **Trimming** — removes leading and trailing whitespace via {@link formatToTrim}.\n * 3. **Validation** — ensures the result is non-empty with {@link isStrFilled}.\n * 4. **Lowercasing** — calls `String.prototype.toLowerCase()` on the trimmed text.\n * 5. If the string is empty or not valid at any step, returns `\"\"`.\n *\n * ### Error safety\n * - The function **never throws**, regardless of input type.\n * - Non-string inputs (numbers, booleans, objects, arrays, `null`, `undefined`) all yield `\"\"`.\n *\n * ### Use cases\n * - Case-insensitive string comparison (normalize both sides with `formatToLowerCase`).\n * - Normalizing user input before storing or indexing.\n * - Simplifying logic where optional strings may be `null` or empty.\n *\n * ### Performance\n * - Time complexity: **O(n)** (where `n` = string length, due to trimming and lowercasing).\n * - Space complexity: **O(n)** (new string created by normalization).\n *\n * ### Examples\n *\n * @example\n * // Basic strings\n * formatToLowerCase('HELLO');        // => \"hello\"\n * formatToLowerCase('  TEST ');      // => \"test\"\n *\n * @example\n * // Mixed types\n * formatToLowerCase(123);            // => \"\"\n * formatToLowerCase(true);           // => \"\"\n * formatToLowerCase(null);           // => \"\"\n *\n * @example\n * // Empty or whitespace inputs\n * formatToLowerCase('   ');          // => \"\"\n * formatToLowerCase('');             // => \"\"\n *\n * @example\n * // Already lowercase\n * formatToLowerCase('data');         // => \"data\"\n *\n * @see isStr\n * @see isStrFilled\n * @see formatToTrim\n *\n * @category String\n * @public\n * @since 2.0.0\n */\nexport function formatToLowerCase(value?: unknown): string {\n\tif (!isStr(value)) {\n\t\treturn '';\n\t}\n\tconst trimmed = formatToTrim(value);\n\t\n\treturn isStrFilled(trimmed) ? trimmed.toLowerCase() : '';\n}\n","import { \n\tisStrFilled,\n\tisStr,\n\tformatToLowerCase, \n} from '../index';\n\nexport function formatToNormalCase(value?: unknown): string {\n\tif (!isStr(value)) {\n\t\treturn '';\n\t}\n\tconst parsed = formatToLowerCase(value);\n\t\n\treturn isStrFilled(parsed) ? (parsed[0].toUpperCase() + parsed.slice(1)) : '';\n}\n","import { \n\tisStr,\n\tformatToTrim,\n\tformatToUndefined, \n} from '../index';\n\n/**\n * Converts `undefined` or empty (whitespace-only) strings into `null`.\n *\n * @summary\n * Safely normalizes optional values by replacing both `undefined` and blank strings\n * with `null`, while preserving all other values as-is.  \n * This helps unify \"missing\" or \"empty\" values under a single, database-friendly\n * `null` representation.\n *\n * @param value - Any input value that may be a string, `undefined`, or another type.\n *\n * @returns\n * - `null` if:\n *   - The input is `undefined`, or\n *   - The input is a string that becomes empty after trimming (using {@link formatToTrim}).\n * - Otherwise returns the original `value`.\n *\n * @remarks\n * ### Processing steps\n * 1. If `value` is `undefined`, returns `null`.\n * 2. If `value` is a string:\n *    - Trims it with {@link formatToTrim}, removing whitespace and invisible characters.\n *    - If the trimmed result is empty (`''`), returns `null`.\n * 3. Otherwise returns the original value unchanged.\n *\n * ### Behavior notes\n * - Non-string, defined values (like `0`, `false`, `{}`, `[]`) are **not modified**.\n * - The function is **pure** (non-mutating) and safe for use in JSON or ORM normalization.\n * - Often used to prepare form data, REST payloads, or DB entities for consistent nullability.\n *\n * ### Comparison with {@link formatToUndefined}\n * | Case | `formatToNull` | `formatToUndefined` |\n * |------|----------------|----------------------|\n * | `undefined` | `null` | `undefined` |\n * | `''` (empty string) | `null` | `undefined` |\n * | `'text'` | `'text'` | `'text'` |\n * | non-string (e.g. `0`) | `0` | `0` |\n *\n * ### Use cases\n * - Unifying “empty” form values before DB insertion (`''` or `undefined` → `null`)\n * - Sanitizing request bodies before persistence or validation\n * - Preventing inconsistent null/undefined states across backend and frontend layers\n *\n * ### Performance\n * - Time complexity: **O(n)** (depends on string length)\n * - Space complexity: **O(n)** (creates a trimmed string copy)\n *\n * ### Examples\n *\n * @example\n * // Empty and whitespace strings\n * formatToNull('');          // => null\n * formatToNull('   ');       // => null\n *\n * @example\n * // Undefined also becomes null\n * formatToNull(undefined);   // => null\n *\n * @example\n * // Non-empty strings remain as-is\n * formatToNull('Hello');     // => \"Hello\"\n * formatToNull('  Data ');   // => \"  Data \"\n *\n * @example\n * // Non-string types are preserved\n * formatToNull(0);           // => 0\n * formatToNull(false);       // => false\n * formatToNull([]);          // => []\n * formatToNull({});          // => {}\n *\n * @see isStr\n * @see formatToTrim\n * @see formatToUndefined\n *\n * @category String\n * @public\n * @since 2.0.0\n */\nexport function formatToNull(value: unknown) {\n\treturn ((isStr(value) && formatToTrim(value) === '') || value === undefined) ? null : value;\n}\n","import { \n\tisStr,\n\tformatToTrim, \n} from '../index';\n\n/**\n * Normalizes and validates a phone number into international format (`E.164` style).\n *\n * @summary\n * Converts various human-entered phone number formats (with spaces, dashes, parentheses,\n * or local prefixes) into a clean, standardized string beginning with `\"+\"`\n * and containing 10–15 digits.\n *\n * Returns `null` if the value is not a valid phone number after normalization.\n *\n * @param value - The input value to format. Can be any unknown type; only strings are processed.\n * @param defaultCountry - Optional international prefix to prepend for 10-digit local numbers\n *                         (defaults to `\"+7\"` — Russia/Kazakhstan).  \n *                         Use your target country code (e.g., `\"+34\"` for Spain, `\"+1\"` for USA).\n *\n * @returns\n * A normalized phone number in `+XXXXXXXXXX` format if valid, or `null` if the input\n * cannot be interpreted as a valid number.\n *\n * @remarks\n * ### Normalization rules\n * 1. **Input validation:**  \n *    If `value` is not a string, returns `null`.\n *\n * 2. **Trimming and cleaning:**  \n *    Removes all whitespace, hyphens, parentheses, and dots.\n *    Example:  \n *    `\" (123) 456-7890 \"` → `\"1234567890\"`.\n *\n * 3. **International formats:**\n *    - `00` prefix (common in Europe) is replaced with `\"+\"`.  \n *      → `\"0049123456789\"` → `\"+49123456789\"`.\n *\n * 4. **Local numbers (10 digits):**  \n *    Prepends the `defaultCountry` code.  \n *    → `\"1234567890\"` → `\"+71234567890\"` (default country `+7`).\n *\n * 5. **Generic international numbers (9–15 digits):**  \n *    If not starting with `\"0\"`, adds `\"+\"` prefix.  \n *    → `\"380501234567\"` → `\"+380501234567\"`.\n *\n * 6. **Validation check:**  \n *    The result must match the pattern `/^\\+\\d{10,15}$/`  \n *    — i.e., plus sign followed by 10–15 digits.  \n *    If not, returns `null`.\n *\n * ### Error safety\n * - Never throws — all invalid or unexpected inputs return `null`.\n * - Automatically cleans up common formatting symbols without side effects.\n *\n * ### Performance\n * - Time complexity: **O(n)** (string length).\n * - Space complexity: **O(n)** (new string creation during cleanup).\n *\n * ### Common pitfalls\n * - Numbers starting with `\"0\"` are **rejected**, since they are ambiguous.\n * - 8-digit local formats are not automatically expanded — use a country-specific parser if needed.\n * - This function performs **basic formatting and validation**, not full ITU-T E.164 compliance.\n *\n * ### Examples\n *\n * @example\n * // International format already valid\n * formatToPhone('+380501234567');         // => \"+380501234567\"\n *\n * @example\n * // European \"00\" prefix\n * formatToPhone('00442079460729');        // => \"+442079460729\"\n *\n * @example\n * // Local 10-digit number (default country +7)\n * formatToPhone('9123456789');            // => \"+79123456789\"\n *\n * @example\n * // With custom default country\n * formatToPhone('9876543210', '+34');     // => \"+349876543210\"\n *\n * @example\n * // Strings with spaces, punctuation, parentheses\n * formatToPhone('(050) 123-45-67');       // => \"+70501234567\"\n * formatToPhone('+1 (202) 555-0183');     // => \"+12025550183\"\n *\n * @example\n * // Invalid or ambiguous inputs\n * formatToPhone('');                      // => null\n * formatToPhone('000123456');             // => null\n * formatToPhone('abcdefgh');              // => null\n * formatToPhone(null);                    // => null\n * formatToPhone(true);                    // => null\n *\n * @see isStr\n * @see formatToTrim\n *\n * @category String\n * @public\n * @since 2.0.0\n */\nexport function formatToPhone(value?: unknown, defaultCountry = '+7'): string | null {\n\tif (!isStr(value)) {\n\t\treturn null;\n\t}\n\tlet phone = formatToTrim(value).replace(/[\\s\\-().]/g, '');\n\n\tif (/^00\\d{8,15}$/.test(phone)) {\n\t\tphone = '+' + phone.slice(2);\n\t}\n\telse if (/^\\d{10}$/.test(phone)) {\n\t\tphone = defaultCountry + phone;\n\t}\n\telse if (/^\\d{9,15}$/.test(phone) && !phone.startsWith('0')) {\n\t\tphone = '+' + phone;\n\t}\n\treturn /^\\+\\d{10,15}$/.test(phone) ? phone : null;\n}\n","import { isStr } from '../index';\n\n\n/**\n * Trims, normalizes, and cleans up invisible characters from a string.\n *\n * @summary\n * Safely converts any input into a clean, Unicode-normalized string with all\n * leading/trailing whitespace removed and zero-width characters stripped out.\n *  \n * Returns an empty string (`\"\"`) for all non-string inputs.\n *\n * @param value - Any value that may contain text or string-like content.\n *\n * @returns A normalized, trimmed string without invisible Unicode separators.\n * Returns an empty string if `value` is not a string.\n *\n * @remarks\n * ### Processing steps\n * 1. **Type check:**  \n *    Uses {@link isStr} to ensure the input is a string.  \n *    Non-strings are converted to `\"\"`.\n *\n * 2. **Trimming:**  \n *    Removes all leading and trailing whitespace (`String.prototype.trim()`).\n *\n * 3. **Unicode normalization:**  \n *    Applies `normalize('NFKC')` — Compatibility Composition — which:\n *    - Converts full-width and compatibility forms into canonical ones.  \n *      Example: `\"ＡＢＣ\"` → `\"ABC\"`.\n *    - Normalizes composed characters (e.g., `\"é\"` vs `\"é\"`).\n *\n * 4. **Invisible character cleanup:**  \n *    Removes hidden zero-width Unicode characters commonly introduced by copy/paste:\n *    - `U+200B` ZERO WIDTH SPACE  \n *    - `U+200C` ZERO WIDTH NON-JOINER  \n *    - `U+200D` ZERO WIDTH JOINER  \n *    - `U+FEFF` ZERO WIDTH NO-BREAK SPACE (BOM)\n *\n * 5. **Safe stringification:**  \n *    Non-string values are returned as empty string rather than `\"undefined\"` or `\"null\"`.\n *\n * ### Benefits\n * - Eliminates subtle text differences that break comparisons or hashing.\n * - Prevents user input issues caused by hidden characters.\n * - Safe to use in both frontend and backend environments.\n *\n * ### Performance\n * - Time complexity: **O(n)** — proportional to the input string length.\n * - Space complexity: **O(n)** — creates a new normalized copy.\n *\n * ### Common use cases\n * - Sanitizing user input before validation or storage.\n * - Cleaning keys, tags, and names from external data sources.\n * - Preparing values for strict equality or hashing.\n *\n * ### Examples\n *\n * @example\n * // Basic trimming\n * formatToTrim('  Hello  ');            // => \"Hello\"\n *\n * @example\n * // Removes zero-width characters\n * formatToTrim('word\\u200B');           // => \"word\"\n *\n * @example\n * // Unicode normalization\n * formatToTrim('ＡＢＣ');               // => \"ABC\"\n * formatToTrim('e\\u0301');              // => \"é\"\n *\n * @example\n * // Non-string inputs\n * formatToTrim(123);                    // => \"\"\n * formatToTrim(null);                   // => \"\"\n * formatToTrim(undefined);              // => \"\"\n * formatToTrim({ text: 'hi' });         // => \"\"\n *\n * @see isStr\n * @see String.prototype.normalize\n *\n * @category String\n * @public\n * @since 2.0.0\n */\nexport function formatToTrim(value: unknown): string {\n\treturn String(isStr(value) ? value.trim().normalize('NFKC').replace(/[\\u200B-\\u200D\\uFEFF]/g, '') : '');\t\n}\n","import { \n\tisStr,\n\tformatToTrim,\n\tformatToNull, \n} from '../index';\n\n/**\n * Converts `null` or empty (whitespace-only) strings into `undefined`.\n *\n * @summary\n * Normalizes optional values by replacing both `null` and blank strings\n * with `undefined`, while keeping all other values unchanged.  \n * This is useful when preparing objects for APIs or serialization,\n * where `undefined` fields are automatically omitted or ignored.\n *\n * @param value - Any value that may be a string, `null`, or another type.\n *\n * @returns\n * - `undefined` if:\n *   - The value is `null`, or\n *   - The value is a string that becomes empty after trimming (via {@link formatToTrim}).\n * - Otherwise returns the original value.\n *\n * @remarks\n * ### Processing steps\n * 1. If `value` is `null`, return `undefined`.\n * 2. If `value` is a string:\n *    - Trim using {@link formatToTrim} to remove whitespace and invisible characters.\n *    - If trimmed result is empty, return `undefined`.\n * 3. Otherwise, return the original value unchanged.\n *\n * ### Behavior notes\n * - Non-string, non-null values (`0`, `false`, `{}`, `[]`, etc.) are **not modified**.\n * - The function is **non-mutating** — it never changes the original reference.\n * - It complements {@link formatToNull}, depending on whether your system\n *   prefers `undefined` (omit field) or `null` (explicit empty value).\n *\n * ### Comparison with {@link formatToNull}\n * | Case | `formatToNull` | `formatToUndefined` |\n * |------|----------------|----------------------|\n * | `null` | `null` | `undefined` |\n * | `undefined` | `null` | `undefined` |\n * | `''` (empty string) | `null` | `undefined` |\n * | `'text'` | `'text'` | `'text'` |\n * | Non-string (e.g. `0`) | `0` | `0` |\n *\n * ### Use cases\n * - Preparing data before sending to REST or GraphQL APIs  \n *   (so empty fields are omitted during JSON serialization)\n * - Cleaning form input values before saving or validation\n * - Ensuring `undefined` consistency in optional object properties\n *\n * ### Performance\n * - Time complexity: **O(n)** (depends on string length)\n * - Space complexity: **O(n)** (due to string trimming)\n *\n * ### Examples\n *\n * @example\n * // Empty and whitespace-only strings\n * formatToUndefined('');        // => undefined\n * formatToUndefined('   ');     // => undefined\n *\n * @example\n * // null is also normalized\n * formatToUndefined(null);      // => undefined\n *\n * @example\n * // Non-empty strings remain unchanged\n * formatToUndefined('Hello');   // => \"Hello\"\n *\n * @example\n * // Non-string types are preserved\n * formatToUndefined(0);         // => 0\n * formatToUndefined(false);     // => false\n * formatToUndefined([]);        // => []\n * formatToUndefined({});        // => {}\n *\n * @see isStr\n * @see formatToTrim\n * @see formatToNull\n *\n * @category String\n * @public\n * @since 2.0.0\n */\nexport function formatToUndefined(value: unknown) {\n\treturn ((isStr(value) && formatToTrim(value) === '') || value === null) ? undefined : value\n}\n","import { \n\tisNum,\n\tformatToNum, \n} from '../index';\n\nconst KB = 1024;\nconst MB = KB * 1024;\nconst GB = MB * 1024;\nconst TB = GB * 1024;\nconst PB = TB * 1024;\n\n/**\n * Converts a numeric value with a given unit (bytes, KB, MB, GB, TB, PB)\n * into gigabytes (`GB`).\n *\n * @summary\n * Safely normalizes a size value of any supported unit into **gigabytes**,\n * using binary multiples (`1 KB = 1024 bytes`, `1 MB = 1024 KB`, etc.).\n *\n * @param value - Numeric value to convert (e.g., `512`, `\"1.5\"`, `\"2048MB\"`).\n * @param unit - Optional unit string indicating the scale of `value`.\n *               Case-insensitive. Supported prefixes:\n *               `\"B\"`, `\"KB\"`, `\"MB\"`, `\"GB\"`, `\"TB\"`, `\"PB\"`.\n *\n * @returns The value converted to gigabytes (`number`).\n *\n * @throws {Error}  \n * Throws an error if the input value cannot be parsed as a finite number,  \n * or if the computed result is `NaN` or `Infinity`.\n *\n * @remarks\n * ### Supported units\n * | Unit | Interpreted as | Conversion formula |\n * |------|----------------|--------------------|\n * | `b`, `B`, `bytes`     | bytes              | `v / GB` |\n * | `k`, `kb`, `kilobyte` | kilobytes          | `v / MB` |\n * | `m`, `mb`, `megabyte` | megabytes          | `v / GB` |\n * | `g`, `gb`, `gigabyte` | gigabytes          | `v` |\n * | `t`, `tb`, `terabyte` | terabytes          | `v * 1024` |\n * | `p`, `pb`, `petabyte` | petabytes          | `v * (1024²)` |\n *\n * If no unit is provided, gigabytes (`GB`) are assumed by default.\n *\n * ### Normalization steps\n * 1. Convert `value` to a numeric value using {@link formatToNum}.\n * 2. Validate via {@link isNum} — must be finite.\n * 3. Normalize `unit`:\n *    - Trim whitespace.\n *    - Convert to lowercase.\n *    - Extract first character (e.g., `'k'` for `\"KB\"`).\n * 4. Compute conversion factor depending on the first letter.\n * 5. Normalize `-0` to `0` before returning.\n *\n * ### Behavior notes\n * - Throws descriptive errors on invalid inputs.\n * - Supports string-based numeric inputs (`\"2048\"`, `\"1.5\"`, etc.).\n * - Ignores case and trailing spaces in the unit name.\n * - Uses binary (IEC-style) 1024-based units — not SI 1000-based.\n *\n * ### Performance\n * - Time complexity: **O(1)**.\n * - Space complexity: **O(1)**.\n *\n * ### Examples\n *\n * @example\n * // Basic conversions\n * toGB(1024, 'MB');   // => 1\n * toGB(1, 'GB');      // => 1\n * toGB(1, 'TB');      // => 1024\n * toGB(0.5, 'TB');    // => 512\n *\n * @example\n * // From bytes\n * toGB(1073741824, 'B'); // => 1\n * toGB('2147483648', 'b'); // => 2\n *\n * @example\n * // From petabytes\n * toGB(1, 'PB'); // => 1048576\n *\n * @example\n * // Auto-handling and normalization\n * toGB(' 1.5 ', ' mb ');   // => 0.00146484375\n * toGB('2', '');           // => 2  (default is GB)\n *\n * @example\n * // Invalid inputs\n * toGB('abc', 'GB');       // throws Error(\"toGB: value \"abc\" is not numeric\")\n * toGB(NaN, 'MB');         // throws Error(\"toGB: result is not finite...\")\n *\n * @see isNum\n * @see formatToNum\n *\n * @category Conversion\n * @public\n * @since 2.0.0\n */\nexport function toGB(value: unknown, unit = ''): number {\n\tconst v = formatToNum(value as any);\n\t\n\tif (!isNum(v)) {\n\t\tthrow new Error(`toGB: value \"${value}\" is not numeric`);\n\t}\n\tconst u = String(unit).trim().toLowerCase().replace(/\\s+/g, '');\n\tconst c = u ? u[0] : 'g';\n\tlet out: number;\n\t\n\tswitch (c) {\n\t\tcase 'b':\n\t\t\tout = v / GB;\n\t\t\tbreak;\n\t\tcase 'k':\n\t\t\tout = v / MB;\n\t\t\tbreak;\n\t\tcase 'm':\n\t\t\tout = v / GB;\n\t\t\tbreak;\n\t\tcase 'g':\n\t\t\tout = v;\n\t\t\tbreak;\n\t\tcase 't':\n\t\t\tout = v * (TB / GB);\n\t\t\tbreak;\n\t\tcase 'p':\n\t\t\tout = v * (PB / GB);\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tout = v;\n\t\t\tbreak;\n\t}\n\tif (!isNum(out)) {\n\t\tthrow new Error(`toGB: result is not finite (value=\"${value}\", unit=\"${unit}\")`);\n\t}\n\treturn Object.is(out, -0) ? 0 : out;\n}\n","\nexport function normalizeUnit(u: string): string {\n\treturn String(u)\n\t\t.trim()\n\t\t.toLowerCase()\n\t\t.replace(/\\s+/g, '')\n\t\t.replace(/(?:\\/?s|hash(?:es)?)$/i, '');\n}\n","import { \n\tisNum,\n\tformatToNum, \n} from '../index';\nimport { normalizeUnit } from './normalizeUnit';\n\nconst FACTOR: Record<string, number> = {\n\th: 1e-9,\n\tk: 1e-6,\n\tm: 1e-3,\n\tg: 1,\n\tt: 1e3,\n\tp: 1e6,\n\te: 1e9,\n};\n\n/**\n * Converts a hashrate (or similar magnitude value) into **gigahashes per second** (`GH/s`).\n *\n * @summary\n * Normalizes a numeric value expressed in various hash rate units (e.g., `kH/s`, `MH/s`, `TH/s`)\n * to **gigahashes (GH)**, using standard decimal scaling (`×1000` between adjacent prefixes).\n *\n * @param value - Input numeric value or string representing a number (e.g. `\"1200\"`, `3.5`).\n * @param unit - Optional unit string representing the magnitude (`H`, `kH`, `MH`, `GH`, `TH`, `PH`, `EH`).\n *               Case-insensitive and automatically normalized via {@link normalizeUnit}.\n *\n * @returns The normalized value expressed in **gigahashes per second (GH/s)**.\n * Returns `0` if the input is invalid or non-numeric.\n *\n * @remarks\n * ### Conversion logic\n * 1. **Parsing:**  \n *    Uses {@link formatToNum} to safely convert `value` into a number.\n *\n * 2. **Validation:**  \n *    If the parsed number is not finite (`NaN`, `Infinity`, etc.), returns `0`.\n *\n * 3. **Unit normalization:**  \n *    Calls {@link normalizeUnit} to clean up and simplify the unit name (e.g. `\" MH/s \"` → `\"mh\"`).\n *    Then takes the first character (`m`, `g`, `t`, etc.) to determine scale.\n *\n * 4. **Factor lookup:**  \n *    Applies the following conversion factors relative to gigahashes:\n *\n *    | Prefix | Unit      | Factor (to GH) | Example conversion             |\n *    |---------|-----------|----------------|--------------------------------|\n *    | `h`     | hashes/s  | `1e-9`         | `1e9 H/s` = `1 GH/s`           |\n *    | `k`     | kilohash  | `1e-6`         | `1e6 kH/s` = `1 GH/s`          |\n *    | `m`     | megahash  | `1e-3`         | `1e3 MH/s` = `1 GH/s`          |\n *    | `g`     | gigahash  | `1`            | identity                       |\n *    | `t`     | terahash  | `1e3`          | `1 TH/s` = `1000 GH/s`         |\n *    | `p`     | petahash  | `1e6`          | `1 PH/s` = `1,000,000 GH/s`    |\n *    | `e`     | exahash   | `1e9`          | `1 EH/s` = `1,000,000,000 GH/s`|\n *\n * 5. **Result validation:**  \n *    If the final result is not a finite number, throws an error.\n *    Otherwise returns the computed gigahashes value (with `-0` normalized to `0`).\n *\n * ### Behavior notes\n * - Returns `0` instead of throwing when the input cannot be parsed as a number.\n * - Uses **decimal scaling** (`×1000`), not binary (`×1024`).\n * - Handles both numeric and string inputs seamlessly.\n * - Automatically ignores plural or rate suffixes (like `/s`, `hashes`).\n *\n * ### Performance\n * - Time complexity: **O(1)**.\n * - Space complexity: **O(1)**.\n *\n * ### Examples\n *\n * @example\n * // Basic conversions\n * toGH(1, 'GH');     // => 1\n * toGH(1, 'TH');     // => 1000\n * toGH(1, 'MH');     // => 0.001\n * toGH(1, 'kH');     // => 0.000001\n * toGH(1, 'PH');     // => 1_000_000\n * toGH(1, 'EH');     // => 1_000_000_000\n *\n * @example\n * // String inputs and normalization\n * toGH('1200', 'mh/s');   // => 1.2\n * toGH('3.5', 'TH/s');    // => 3500\n *\n * @example\n * // Invalid or edge inputs\n * toGH('', 'GH');         // => 0\n * toGH(null, 'GH');       // => 0\n * toGH(NaN, 'MH');        // => 0\n *\n * @example\n * // Custom normalization of unit formatting\n * toGH(5, ' khash / s '); // => 0.000005\n * toGH(2, 'T');           // => 2000\n *\n * @see formatToNum\n * @see isNum\n * @see normalizeUnit\n *\n * @category Conversion\n * @public\n * @since 2.0.0\n */\nexport function toGH(value: any, unit = ''): number {\n\tconst v = formatToNum(value);\n\n\tif (!isNum(v)) {\n\t\treturn 0;\n\t}\n\tconst u = normalizeUnit(unit);\n\tconst c = u ? u[0] : 'g';\n\tconst factor = FACTOR[c] ?? 1;\n\tconst out = v * factor;\n\n\tif (!isNum(out)) {\n\t\tthrow new Error(`toGH: result is not finite (value=\"${v}\", unit=\"${u}\")`);\n\t}\n\treturn Object.is(out, -0) ? 0 : out;\n}","import { \n\tisNum,\n\tformatToNum,\n} from '../index';\nimport { normalizeUnit } from './normalizeUnit';\n\nconst FACTOR_H: Record<string, number> = {\n\th: 1,\n\tk: 1e3,\n\tm: 1e6,\n\tg: 1e9,\n\tt: 1e12,\n\tp: 1e15,\n\te: 1e18,\n};\n\n/**\n * Converts a rate value expressed with SI hash-rate prefixes into **hashes per second** (`H/s`).\n *\n * @summary\n * Normalizes a numeric value given in `kH/s`, `MH/s`, `GH/s`, `TH/s`, `PH/s`, or `EH/s`\n * to plain **hashes per second** using **decimal scaling** (×1000 between adjacent prefixes).\n * Units are case-insensitive and sanitized via {@link normalizeUnit}.\n *\n * @param value - Input value to convert (number or number-like string, e.g. `3.5`, `\"1200\"`).\n * @param unit - Optional unit string (e.g. `\"kH/s\"`, `\"MH\"`, `\"ghashes\"`).  \n *               If omitted or empty, the function assumes **`h`** (hashes).\n *\n * @returns The value converted to **H/s** (`number`). Returns `0` if `value` is not numeric.\n *\n * @remarks\n * ### Unit handling\n * `unit` is first cleaned by {@link normalizeUnit} (trim, lowercase, remove spaces and `\"/s\"`, `\"hash(es)\"`),\n * then the **first character** determines the scale:\n *\n * | Prefix | Interpreted as | Multiplier to H/s |\n * |:------:|-----------------|-------------------|\n * | `h`    | hashes          | `1`               |\n * | `k`    | kilohashes      | `1e3`             |\n * | `m`    | megahashes      | `1e6`             |\n * | `g`    | gigahashes      | `1e9`             |\n * | `t`    | terahashes      | `1e12`            |\n * | `p`    | petahashes      | `1e15`            |\n * | `e`    | exahashes       | `1e18`            |\n *\n * Unknown or empty prefixes default to `h` (no scaling).\n *\n * ### Parsing & validation\n * - Uses {@link formatToNum} to parse `value`.\n * - If parsed value is not a finite number, returns `0`.\n * - After conversion, if the result is not finite, throws an error with details.\n * - Normalizes `-0` to `0` before returning.\n *\n * ### Decimal vs binary\n * This function uses **decimal** (SI) steps (×1000) common for hashrates.\n * For byte/size conversions use binary (×1024) helpers like `toGB`.\n *\n * ### Performance\n * - Time complexity: **O(1)**\n * - Space complexity: **O(1)**\n *\n * ### Examples\n *\n * @example\n * // Identity and basic scales\n * toH(1, 'H');     // => 1\n * toH(1, 'kH');    // => 1_000\n * toH(1, 'MH');    // => 1_000_000\n * toH(1, 'GH');    // => 1_000_000_000\n * toH(2.5, 'TH');  // => 2_500_000_000_000\n *\n * @example\n * // Large magnitudes\n * toH(1, 'PH');    // => 1_000_000_000_000_000\n * toH(0.01, 'EH'); // => 10_000_000_000_000_000\n *\n * @example\n * // Flexible, noisy units and strings\n * toH('1200', ' mh/s ');     // => 1_200_000\n * toH(3.2, 'khashes');       // => 3_200\n * toH('5', '');              // => 5   (defaults to hashes)\n *\n * @example\n * // Invalid inputs\n * toH('', 'GH');             // => 0\n * toH(null, 'MH');           // => 0\n * toH(NaN, 'kH');            // => 0\n *\n * @see normalizeUnit\n * @see formatToNum\n * @see isNum\n *\n * @category Conversion\n * @public\n * @since 2.0.0\n */\nexport function toH(value: any, unit = ''): number {\n\tconst v = formatToNum(value);\n\n\tif (!isNum(v)) {\n\t\treturn 0;\n\t}\n\tconst u = normalizeUnit(unit);\n\tconst c = u ? u[0] : 'h';\n\tconst factor = FACTOR_H[c] ?? 1;\n\tconst out = v * factor;\n\n\tif (!isNum(out)) {\n\t\tthrow new Error(`toH: result is not finite (value=\"${v}\", unit=\"${u}\")`);\n\t}\n\treturn Object.is(out, -0) ? 0 : out;\n}\n","import { isStrFilled } from '../index';\n\nconst HAS_SCHEME = /^[a-zA-Z][a-zA-Z\\d+\\-.]*:/;\n\n/**\n * Extracts the **hostname** (IPv4, IPv6, or domain) from a URL-like string.\n *\n * @summary\n * Parses a given string as a URL or host reference and returns the **host component**\n * (without protocol, port, path, query, or credentials).  \n * Handles both valid URLs (via {@link URL}) and malformed or scheme-less inputs using fallback parsing.\n *\n * @param value - Any string that may represent a URL, host, or address.\n *\n * @returns\n * The hostname (domain or IP address) as a plain string.  \n * Returns an empty string (`\"\"`) if the input is blank or cannot be parsed.\n *\n * @remarks\n * ### Parsing strategy\n * 1. **Scheme detection:**  \n *    - If the input starts with a protocol scheme (e.g., `http:`, `ftp:`), it is parsed directly.  \n *    - Otherwise, a default `http://` prefix is prepended so the built-in {@link URL} parser can process it.\n *\n * 2. **Primary parsing:**  \n *    - Uses the native {@link URL} class to extract `hostname`.\n *    - Automatically handles IPv6 literals, punycode domains, and IDNs.\n *\n * 3. **Fallback parsing (for invalid URLs):**  \n *    - Strips credentials (`user:pass@`).\n *    - Extracts the first segment before `/`, `?`, or `#`.\n *    - If the result looks like `[::1]` or `[2001:db8::1]`, returns the IPv6 address inside brackets.\n *    - Otherwise, takes everything before the first colon (`:`) as the hostname.\n *\n * ### Supported formats\n * - Full URLs:  \n *   `\"https://user:pass@sub.example.com:8080/path\"` → `\"sub.example.com\"`\n * - Host with port:  \n *   `\"example.com:3000\"` → `\"example.com\"`\n * - IPv4:  \n *   `\"192.168.1.1:4028\"` → `\"192.168.1.1\"`\n * - IPv6 (with or without brackets):  \n *   `\"[2001:db8::1]:4028\"` → `\"2001:db8::1\"`\n * - Without scheme:  \n *   `\"example.com/test?q=1\"` → `\"example.com\"`\n *\n * ### Behavior notes\n * - Returns an empty string if `value` is empty, blank, or unparsable.\n * - Never throws — all exceptions are caught and handled gracefully.\n * - Does **not** include port numbers or authentication info.\n * - Automatically trims whitespace before parsing.\n *\n * ### Performance\n * - Time complexity: **O(n)** (linear in string length).\n * - Space complexity: **O(n)** (creates trimmed and split substrings).\n *\n * ### Examples\n *\n * @example\n * // Standard URLs\n * extractHost('https://example.com/path');         // => \"example.com\"\n * extractHost('http://user:pass@site.org:8080');   // => \"site.org\"\n *\n * @example\n * // Without scheme\n * extractHost('example.com/foo/bar');              // => \"example.com\"\n * extractHost('sub.domain.net:3000');              // => \"sub.domain.net\"\n *\n * @example\n * // IP addresses\n * extractHost('192.168.0.10:4028');                // => \"192.168.0.10\"\n * extractHost('[2001:db8::1]:80');                 // => \"2001:db8::1\"\n *\n * @example\n * // Invalid or blank input\n * extractHost('');                                 // => \"\"\n * extractHost('not a valid host');                 // => \"not\"\n *\n * @see URL\n * @see isStrFilled\n *\n * @category Network\n * @public\n * @since 2.0.0\n */\nexport function extractHost(value: string = ''): string {\n\tif (!isStrFilled(value)) {\n\t\treturn '';\n\t}\n\tlet v = value.trim();\n\tconst candidate = HAS_SCHEME.test(v) ? v : `http://${v}`;\n\n\ttry {\n\t\tconst u = new URL(candidate);\n\t\tlet host = u.hostname;\n\n\t\treturn host;\n\t}\n\tcatch {\n\t\tconst withoutCreds = v.split('@').pop() || v;\n\t\tconst firstSegment = withoutCreds.split(/[/?#]/, 1)[0];\n\t\tconst mIPv6 = firstSegment.match(/^\\[([^\\]]+)\\]/);\n\t\t\n\t\tif (mIPv6) {\n\t\t\treturn mIPv6[1];\n\t\t}\n\t\treturn firstSegment.split(':', 1)[0] || '';\n\t}\n}\n"]}