UNPKG

@leancodepl/utils

Version:

Common utility functions and React hooks for web applications

30 lines (29 loc) 1.27 kB
import { CapitalizeDeep, UncapitalizeDeep } from "./types"; /** * Recursively transforms all object keys to use uncapitalized (camelCase) format. * * @template T - The type of the input value * @param value - The value to transform (can be object, array, or primitive) * @returns A new object with all keys converted to camelCase * @example * ```typescript * const serverData = { UserId: 1, UserName: 'John', Profile: { FirstName: 'John' } }; * const clientData = uncapitalizeDeep(serverData); * // Result: { userId: 1, userName: 'John', profile: { firstName: 'John' } } * ``` */ export declare function uncapitalizeDeep<T>(value: T): UncapitalizeDeep<T>; /** * Recursively transforms all object keys to use capitalized (PascalCase) format. * * @template T - The type of the input value * @param value - The value to transform (can be object, array, or primitive) * @returns A new object with all keys converted to PascalCase * @example * ```typescript * const clientData = { userId: 1, userName: 'John', profile: { firstName: 'John' } }; * const serverData = capitalizeDeep(clientData); * // Result: { UserId: 1, UserName: 'John', Profile: { FirstName: 'John' } } * ``` */ export declare function capitalizeDeep<T>(value: T): CapitalizeDeep<T>;