@jsonjoy.com/json-type
Version:
High-performance JSON Pointer implementation
24 lines (23 loc) • 845 B
TypeScript
/**
* High-performance string format validation utilities.
* These functions are optimized for maximum performance.
*/
/**
* Validates if a string contains only ASCII characters (0-127).
* This is highly optimized for performance.
*/
export declare const isAscii: (str: string) => boolean;
/**
* Validates if a string represents valid UTF-8 when encoded.
* JavaScript strings are UTF-16, but we need to validate they don't contain
* invalid Unicode sequences that would produce invalid UTF-8.
*
* This checks for:
* - Unpaired surrogates (invalid UTF-16 sequences)
* - Characters that would produce invalid UTF-8
*/
export declare const isUtf8: (str: string) => boolean;
/**
* Validates a string according to the specified format.
*/
export declare const validateStringFormat: (str: string, format: "ascii" | "utf8") => boolean;