deep-case-crafter
Version:
Transforms deeply nested object, array, Map, and Set keys between common case formats while preserving TypeScript type safety
18 lines (17 loc) • 669 B
TypeScript
import { StringCase } from '../types/stringCaseTypes';
/**
* Detects the case format of a string
* @param str - The string to analyze
* @returns The detected case format, 'single' for single words, or null if format cannot be determined
*
* @example
* ```typescript
* detectStringCase('hello_world') // => 'snake'
* detectStringCase('helloWorld') // => 'camel'
* detectStringCase('HelloWorld') // => 'pascal'
* detectStringCase('hello-world') // => 'kebab'
* detectStringCase('hello') // => 'single'
* ```
* @internal This function is for internal use by the library
*/
export default function detectStringCase(str: string): StringCase | 'single' | null;