/*! * ======================================================================== * @rzl-zone/utils-js * ------------------------------------------------------------------------ * Version: `3.15.0` * Author: `Rizalvin Dwiky ` * Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/utils-js` * ======================================================================== */ import { C as NonPlainObject, _ as IsNever } from "./index-Cr6qFcbC.cjs"; declare const ACRONYMS: readonly ["URI", "URL", "URN", "HTTP", "HTTPS", "FTP", "FTPS", "SFTP", "SSH", "SMTP", "POP3", "IMAP", "WS", "WSS", "TCP", "UDP", "IP", "ICMP", "ARP", "RTP", "RTSP", "SIP", "HTML", "XHTML", "XML", "WBR", "CSS", "SVG", "JSON", "JSONP", "DOM", "IDB", "DB", "RTC", "ICE", "TLS", "SSL", "CORS", "WASM", "CSR", "SSR", "PWA", "DPI", "CDN", "JS", "TS", "JSX", "TSX", "CLI", "API", "SDK", "UI", "UX", "OS", "ID", "UUID", "PID", "NPM", "YARN", "ESM", "CJS", "BOM", "MVC", "MVVM", "ORM", "DAO", "CRUD", "FIFO", "LIFO", "OOP", "FP", "REPL", "CSV", "TSV", "SQL", "YAML", "JSON", "MD", "INI", "PDF", "XLS", "XLSX", "RTF", "XML", "BMP", "GIF", "PNG", "JPEG", "WEBP", "MP3", "MP4", "AVI", "MOV", "FLAC", "MKV", "WAV", "URLSearchParams", "XHR", "2D", "3D", "GL", "WebGL", "TTL", "UID", "GID", "MAC", "IP", "DNS", "DHCP", "VPN", "LAN", "WAN", "SSID", "IoT", "API", "SDK", "CLI", "LTS", "EOL", "CPU", "GPU", "RAM", "ROM", "SSD", "HDD", "BIOS", "USB", "PCI", "SATA", "DIMM", "DDR", "VGA", "HDMI", "KVM", "ASIC", "FPGA", "SoC", "NAS", "SAN", "TCP", "UDP", "IP", "MAC", "DNS", "DHCP", "VPN", "LAN", "WAN", "SSID", "NAT", "QoS", "MPLS", "BGP", "OSPF", "ICMP", "IGMP", "LLDP", "ARP", "RARP", "AES", "RSA", "OTP", "MFA", "PKI", "VPN", "IAM", "ACL", "CSP", "XSS", "CSRF", "HSTS", "WAF", "DDoS", "IDS", "IPS", "SOC", "SIEM", "AWS", "GCP", "AZURE", "CI", "CD", "K8S", "IaC", "PaaS", "SaaS", "IaaS", "API", "CLI", "SDK", "REST", "SOAP", "JSON-RPC", "gRPC", "ELB", "EKS", "AKS", "FaaS", "CaaS", "GUI", "IDE", "FAQ", "UX", "UI", "CLI", "API", "SDK", "LTS", "EOL", "WYSIWYG", "CMS", "CRM", "GPS", "LED", "OLED", "LCD", "RFID", "NFC", "CPU", "GPU", "AI", "ML", "DL", "DB", "SQL", "NoSQL", "ORM", "JSON", "XML", "CSV", "HTTP", "HTTPS", "TDD", "BDD", "CI", "CD", "QA", "SLA", "SLO", "MTTR", "MTBF", "UAT", "RPA", "KPI", "OKR", "ROI", "RFP", "SLA", "CRM", "ERP", "PMO", "SCRUM", "KANBAN", "FPS", "HDR", "VR", "AR", "3D", "2D", "MP3", "MP4", "GIF", "PNG", "JPEG", "SVG", "BMP", "TIFF", "POSIX", "NTFS", "FAT", "EXT", "EXT4", "APFS", "HFS", "ISO", "HTML", "CSS", "JS", "TS", "PHP", "SQL", "JSON", "XML", "YAML", "BASH", "ZSH", "JSON", "YAML", "INI", "DOTENV", "VM", "VMM", "VPC", "OCI", "LXC", "Docker", "K8S", "CRI", "CNI"]; /** ---------------------------------------------------------- * * ***List of acronyms to keep uppercase in formatted output.*** * ----------------------------------------------------------- * * - **Behavior:** * - Prevents transformations (like camelCase or kebab-case) from altering * known acronyms such as `HTML`, `URL`, `API`, etc. * - Extend this list if you want more acronyms to remain uppercase. * * --- * - **⚠️ Internal:** * - Used internally by {@link getPreciseType | `getPreciseType`} and related formatters. */ declare const ACRONYMS_DATA: Readonly; /** --------------------------------------------------------------------------- * * ***Options for controlling how {@link getPreciseType | `getPreciseType`} formats and normalizes detected types.*** * ---------------------------------------------------------------------------- * These options customize the string transformation behavior and acronym handling * when converting JavaScript type names to human-readable strings. */ type GetPreciseTypeOptions = { /** ------------------------------------------------------- * * ***Specifies the format in which the returned string type should be transformed.*** * -------------------------------------------------------- * **ℹ️ For special string literals in `SPECIAL_CASES` (`"-Infinity" | "Infinity" | "NaN"`), which will remain unchanged.** * * --- * - #### Supported formats: * - `"toKebabCase"` (default) — words separated by hyphens. * - ➔ `"result-example-type"`. * - `"toLowerCase"` - converts all letters to lowercase. * - ➔ `"result example type"`. * - `"toDotCase"` — words separated by dots. * - ➔ `"result.example.type"`. * - `"toCamelCase"` — first word lowercase, subsequent words capitalized. * - ➔ `"resultExampleType"`. * - `"toSnakeCase"` — words separated by underscores. * - ➔ `"result_example_type"`. * - `"toPascalCase"` — all words capitalized, no spaces. * - ➔ `"ResultExampleType"`. * - `"toPascalCaseSpace"` — all words capitalized with spaces between words. * - ➔ `"Result Example Type"`. * - `"slugify"` — URL-friendly slug (lowercase with hyphens). * - ➔ `"result-example-type"`. * * --- * @default * ```ts * "toKebabCase" * ``` * * --- * @note * ⚠️ If an invalid value is provided, the function will automatically fallback to the default `"toKebabCase"`. */ formatCase?: "toPascalCaseSpace" | "toPascalCase" | "toCamelCase" | "toKebabCase" | "toSnakeCase" | "toDotCase" | "slugify" | "toLowerCase"; /** ------------------------------------------------------- * * ***Control uppercase preservation of recognized acronyms during formatting.*** * -------------------------------------------------------- * When enabled (`true`), common technical acronyms (e.g., `"URL"`, `"HTTP"`, `"HTML"`, `"SVG"`, `"XML"`, `"DOM"`) * are preserved in their original uppercase form instead of being lowercased or altered by case-formatting utilities. * * --- * --- * @description * The list of recognized acronyms is defined in {@link AcronymsList | **`AcronymsList`**}, * including entries like `"URL"`, `"HTTP"`, `"HTML"`, `"SVG"`, `"XML"`, `"DOM"`, and others. * * --- * - ***Behavior:*** * - #### When `false` (default): * - Acronyms are treated as normal words and formatted according to the selected `formatCase`. * - Example: * - `HTMLDivElement` ➔ `"html-div-element"` (with `"toKebabCase"`). * - `DOMParser` ➔ `"dom-parser"`. * * --- * * - #### When `true`: * - Acronyms remain uppercase. * - Example: * - `HTMLDivElement` ➔ `"HTML-div-element"` (with `"toKebabCase"`). * - `DOMParser` ➔ `"DOM-parser"`. * * --- * @default * ```ts * false * ``` * * --- * @note * ⚠️ This option affects **formatting output only**, not the underlying type detection, acronym preservation is applied **after** detecting and formatting the base type name. */ useAcronyms?: boolean; }; /** --------------------------------------------------------------------------- * * ***Type alias for the list of common acronyms preserved in uppercase.*** * ---------------------------------------------------------------------------- * * Use this type to reference the full set of recognized acronyms * used internally by the {@link getPreciseType | **`getPreciseType`**} function for formatting purposes. */ type AcronymsList = typeof ACRONYMS_DATA; /** ---------------------------------------------------------- * * ***Utility-Predicate: `getPreciseType`.*** * ----------------------------------------------------------- * **Returns a detailed and normalized type string for the given value.** * * --- * @description * The returned string is human-readable ***toKebabCase*** with spaces ***(by default)*** or formatted according to the `options.formatCase` setting. * - **Handles:** * - Primitives (`string`, `number`, `boolean`, `null`, `undefined`, `symbol`, `bigint`). * - Built-in objects (`Array`, `Map`, `Set`, `Error subclasses`, `Typed Arrays`, `etc`). * - Objects created with `Object.create(null)`. * - Objects wrapper (`new String`, `new Number`, `new Boolean`). * - DOM Node type (may not be fully accurate outside the browser environment). * - Generator instances. * - Node.js `Buffer` instances. * - Proxy detection (returns `"Proxy"` if detected; detection ***is not 100% accurate***). * - Uses cached mapping table (`FIXES_CASTABLE_TABLE`) for known types to provide consistent naming. * - Falls back to constructor name or `Object.prototype.toString` tag. * * --- * @param {*} value - The value to detect the precise type of. * @param {GetPreciseTypeOptions} [options] - Optional configuration. * @param {GetPreciseTypeOptions["formatCase"]} [options.formatCase="toLowerCase"] * Specifies how the returned type string should be formatted. * - ⚠️ Special string literals in `SPECIAL_CASES` * (`"-Infinity" | "Infinity" | "NaN"`) will remain * unchanged even if a different `formatCase` is applied. * @param {boolean} [options.useAcronyms=false] * Control uppercase preservation of recognized acronyms during formatting. * - When `true`, recognized acronyms such as `"URL"`, `"HTTP"`, `"HTML"`, `"SVG"`, `"XML"`, and `"DOM"` * are preserved in uppercase instead of being lowercased or otherwise transformed. * - When `false` (default), acronyms are formatted like regular words according to `formatCase`. * - ⚠️ This option affects **formatting output only**, not type detection. * * --- * @returns {string} The normalized and formatted type string. * * --- * @example * 1. #### Basic Usage: * ```ts * getPreciseType(123); * // ➔ "number" * getPreciseType(null); * // ➔ "null" * getPreciseType(/regex/); * // ➔ "reg-exp" * getPreciseType(/regex/, { formatCase: "toPascalCase" }); * // ➔ "RegExp" * getPreciseType(function* () {}, { formatCase: "toCamelCase" }); * // ➔ "generatorFunction" * getPreciseType(async function () {}, { formatCase: "toPascalCaseSpace" }); * // ➔ "Async Function" * ``` * --- * 2. #### `SPECIAL_CASES` remain: * ```ts * getPreciseType(NaN, { formatCase: "toLowerCase" }); * // ➔ "NaN" * getPreciseType(Infinity, { formatCase: "toLowerCase" }); * // ➔ "Infinity" * getPreciseType(-Infinity, { formatCase: "toLowerCase" }); * // ➔ "-Infinity" * ``` * --- * 3. #### `Acronym` usage examples: * ```ts * getPreciseType(new URL("https://example.com")); * // ➔ "url" * getPreciseType(new URL("https://example.com"), { useAcronyms: true }); * // ➔ "URL" * getPreciseType(new URLSearchParams, { formatCase: "toPascalCase" }); * // ➔ "UrlSearchParams" * getPreciseType(new URLSearchParams, { formatCase: "toPascalCase", useAcronyms: true }); * // ➔ "URLSearchParams" * ``` */ declare const getPreciseType: (value: unknown, options?: GetPreciseTypeOptions) => string; type IsNumberOptions = { /** --------------------------------------------------------- * * ***If set to `true`, `NaN` will be considered a valid number, defaultValue: `false`.*** * ---------------------------------------------------------- * * @default false */ includeNaN?: boolean; }; /** --------------------------------------------------------- * * ***Type guard: `isNumber`.*** * ---------------------------------------------------------- * **Checks if a value is of type **`number`**.** * * --- * - #### *Behavior:* * - Uses `typeof value === "number"`. * - By default, excludes **`NaN`**. * - If `options.includeNaN` is `true`, then **`NaN`** is also considered valid. * - Still considers `Infinity` and `-Infinity` as **numbers** (consistent with JavaScript). * * --- * - #### *Note:* * - To exclude `Infinity` and `-Infinity`, use **{@link isFinite | `isFinite`}** instead. * * --- * @param {*} value - The value to check. * @param {IsNumberOptions} [options] - Optional settings. * @param {boolean} [options.includeNaN=false] If `true`, `NaN` will be considered a valid number, defaults to `false`, which excludes `NaN`. * * --- * @returns {boolean} Returns `true` if the value is a number (and depending on `includeNaN`, `NaN` is included or excluded). * * --- * @example * isNumber(42); * // ➔ true * isNumber(Infinity); * // ➔ true * isNumber(-Infinity); * // ➔ true * isNumber(NaN); * // ➔ false (default) * isNumber(NaN, { includeNaN: true }); * // ➔ true * isNumber("42"); * // ➔ false */ declare const isNumber: (value: unknown, options?: IsNumberOptions) => value is number; type ArrayFallback = IsNever> extends true ? T & unknown[] : Extract; type IsHasKeysObject = keyof T extends never ? false : true; /** ---------------------------------------------------------- * * ***Utility type: `IsPlainObjectResult`.*** * ----------------------------------------------------------- * **Represents the inferred type after asserting a value is a **plain object**.** * * --- * - **Behavior:** * - If `T` is `unknown`, the resulting type is `Record & T`. * - If `T` is an object: * - If it is a non-plain object (class instance, built-in object, etc.), the result is `never`. * - If it has no keys (`IsHasKeysObject` checked by **{@link IsHasKeysObject|`IsHasKeysObject`}** is false), the result is `Record & T`. * - Otherwise, the result is `T` itself. * - For any other types, the result is `never`. * * --- * @template T - The input type to be asserted as a plain object. * * --- * @example * ```ts * type A = IsPlainObjectResult; * // ➔ Record & unknown * type B = IsPlainObjectResult<{}>; * // ➔ Record & {} * type C = IsPlainObjectResult<{ foo: string }>; * // ➔ { foo: string } * type D = IsPlainObjectResult; * // ➔ never * ``` */ type IsPlainObjectResult = unknown extends T ? Record & T : T extends object ? T extends NonPlainObject ? never : IsHasKeysObject extends false ? Record & T : T : Extract>; /** ---------------------------------------------------------- * * ***Type guard: `isPlainObject`.*** * ----------------------------------------------------------- * **Checks if a value is a **plain-object**.** * * - #### A plain object is: * - Created by the `Object` constructor, or. * - Has a `[[Prototype]]` of `null` (e.g. `Object.create(null)`). * --- * - #### *Behavior:* * - #### Returns `true` for: * - Empty object literals: `{}`. * - Objects with null prototype: `Object.create(null)`. * --- * - #### Returns `false` for: * - Arrays (`[]`, `new Array()`). * - Functions (regular, arrow, or class constructors). * - Built-in objects: `Date`, `RegExp`, `Error`, `Map`, `Set`, `WeakMap`, `WeakSet`. * - Boxed primitives: `new String()`, `new Number()`, `new Boolean()`. * - `null` or `undefined`. * - Symbols. * - Class instances. * * --- * @template T - The type of the value being checked. * * --- * @param {*} value - The value to check. * * --- * @returns {boolean} Return `true` if `value` is a `plain-object`, otherwise `false`. * * --- * @example * isPlainObject({}); * // ➔ true * isPlainObject(Object.create(null)); * // ➔ true * isPlainObject(null); * // ➔ false * isPlainObject(() => {}); * // ➔ false * isPlainObject([1, 2, 3]); * // ➔ false * isPlainObject(new Date()); * // ➔ false * isPlainObject(new MyClass()); * // ➔ false * isPlainObject(new String("x")); * // ➔ false */ declare function isPlainObject(value: T): value is IsPlainObjectResult; declare function isPlainObject(value: T): value is NonNullable>>; export { IsNumberOptions as a, GetPreciseTypeOptions as c, ArrayFallback as i, getPreciseType as l, isPlainObject as n, isNumber as o, IsHasKeysObject as r, AcronymsList as s, IsPlainObjectResult as t };