@alanscodelog/utils
    Preparing search index...

    Function changeObjectKeys

    • Returns a new object with the given function applied to it's keys (shallow). Useful for renaming keys or doing some custom modification.

      import { constantCase } from "change-case"

      const obj = { helloWorld: "hello" }
      const newObj = changeObjectKeys(obj, constantCase)
      // newObject = { HELLO_WORLD: "hello" }

      // newObj must be typed manually
      const newObj = changeObjectKeys<ResType>(obj, constantCase)

      Type Parameters

      • TResObj extends Record<any, any>
      • TObj extends Record<any, any>

      Parameters

      • obj: TObj
      • changeKey: (key: keyof TObj) => string | number | symbol

      Returns TResObj