safers
Version:
Safely convert to the desired data and error-free refine values.
23 lines (22 loc) • 826 B
TypeScript
/**
* Safely converts a value to lowercase.
*
* @param val - The value to be converted to lowercase.
* @param locales - A string with a BCP 47 language tag, or an array of such strings. For the full specification, refer to [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleLowerCase#locales).
*
* @returns The value converted to lowercase.
*
* @example
* // Example 1: When the value is a string
* const result1 = toLowerCase("Hello");
* // Result: "hello"
*
* // Example 2: When the value is a number
* const result2 = toLowerCase(123);
* // Result: "123"
*
* // Example 3: When the value is an empty string
* const result3 = toLowerCase("");
* // Result: ""
*/
export declare function toLowerCase(val: unknown, locales?: string): string;