UNPKG

734 BTypeScriptView Raw
1/**
2 * Use mapKeys to convert object keys to another format using the specified conversion function.
3 *
4 * E.g., to deep convert all object keys to camelCase: mapKeys(myObj, _.camelCase, true)
5 * to shallow convert object keys to lower case: mapKeys(myObj, _.toLower)
6 *
7 * NOTE: This mutates the object passed in for conversion.
8 *
9 * @param target - {Object} The object to convert the keys
10 * @param converter - {Function} The function that converts the object key
11 * @param deep - {boolean} Whether to do a deep object key conversion
12 * @return {Object} - the object with the converted keys
13 */
14export default function mapKeys(obj: any, converter: (key: string) => string, deep?: boolean): Record<string, unknown>;