UNPKG

nhb-toolbox

Version:

A versatile collection of smart, efficient, and reusable utility functions and classes for everyday development needs.

75 lines 3.23 kB
/** * * Type guard to check if a value is a valid email string. * @param value - The value to check. * @returns `true` if the value is a valid email, otherwise `false`. */ export declare function isEmail(value: unknown): value is string; /** * * Type guard to check if a value is an array of valid email strings. * @param value - The value to check. * @returns `true` if the value is an array of valid email strings, otherwise `false`. */ export declare function isEmailArray(value: unknown): value is string[]; /** * * Type guard to check if a value is a valid date string. * @param value - The value to check. * @returns `true` if the value is a valid date string, otherwise `false`. */ export declare function isDateString(value: unknown): value is string; /** * * Type guard to check if a value is a valid UUID (v4). * @param value - The value to check. * @returns `true` if the value is a valid UUID, otherwise `false`. */ export declare function isUUID(value: unknown): value is string; /** * * Type guard to check if the code is running in a browser environment. * @returns `true` if the code is running in a browser, otherwise `false`. */ export declare function isBrowser(): boolean; /** * * Type guard to check if the code is running in a Node.js environment. * @returns `true` if the code is running in Node.js, otherwise `false`. */ export declare function isNode(): boolean; /** * * Type guard to check if a value is a valid URL. * @param value - The value to check. * @returns `true` if the value is a valid URL, otherwise `false`. */ export declare function isURL(value: unknown): value is string; /** * * Type guard to check if a value is a valid Base64 encoded string. * @param value - The value to check. * @returns `true` if the value is a valid Base64 string, otherwise `false`. */ export declare function isBase64(value: unknown): value is string; /** * * Type guard to check if a value is a valid phone number. * @param value - The value to check. * @returns `true` if the value is a valid phone number, otherwise `false`. */ export declare function isPhoneNumber(value: unknown): value is string; /** * * Type guard to check if a value is a valid IP address (IPv4 or IPv6). * @param value - The value to check. * @returns `true` if the value is a valid IP address, otherwise `false`. */ export declare function isIPAddress(value: unknown): value is string; /** * * Type guard to check if the current environment matches a given string. * @param env - The expected environment (e.g., "production", "development"). * @returns `true` if the value is a numeric string parsable by `Number()`, otherwise `false`. */ export declare function isEnvironment(env: string): boolean; /** * * Type guard to check if a value is a string representing a finite number. * * Accepts strings like: `"42"`, `" -5.5 "`, `"0.123"`, `"-0"`, `"1e5"`. * Rejects strings like: `"NaN"`, `"Infinity"`, `"-Infinity"`, `"abc"`, `""`, `"42abc"`. * * @param value - The value to test. * @returns `true` if the value is a string that fully represents a finite number. */ export declare function isNumericString(value: unknown): value is `${number}`; //# sourceMappingURL=specials.d.ts.map