/**
 * Converts all keys of an object to uppercase
 * @param obj The object whose keys need to be converted to uppercase
 * @returns A new object with all keys converted to uppercase
 */
function uppercaseObjectKeys<T extends Record<string, any>>(
  obj: T,
): Record<string, any> {
  if (typeof obj !== "object" || obj === null) {
    return obj;
  }

  return Object.entries(obj).reduce(
    (result, [key, value]) => {
      const uppercaseKey = key.toUpperCase();
        result[uppercaseKey] = typeof value === "object" && value !== null
          ? uppercaseObjectKeys(value)
          : value;
      return result;
    },
    {} as Record<string, any>,
  );
}
export default uppercaseObjectKeys;
