@salesforce/core
Version:
Core libraries to interact with SFDX projects, orgs, and APIs.
15 lines (14 loc) • 721 B
TypeScript
/**
* Use mapKeys to convert object keys to another format using the specified conversion function.
*
* E.g., to deep convert all object keys to camelCase: mapKeys(myObj, _.camelCase, true)
* to shallow convert object keys to lower case: mapKeys(myObj, _.toLower)
*
* NOTE: This mutates the object passed in for conversion.
*
* @param target - {Object} The object to convert the keys
* @param converter - {Function} The function that converts the object key
* @param deep - {boolean} Whether to do a deep object key conversion
* @return {Object} - the object with the converted keys
*/
export default function mapKeys<T>(obj: T, converter: (key: string) => string, deep?: boolean): Record<string, unknown>;