Function objMapKeys

  • Maps the keys of an object using a callback function.

    Type Parameters

    • T

      The type of the values in the object.

    Parameters

    • object: Record<string, T>

      The object whose keys will be mapped.

    • callback: ((key, value) => string)

      The callback function that maps the keys.

        • (key, value): string
        • Parameters

          • key: string
          • value: T

          Returns string

    • getKeys: ((obj) => Iterable<string>) = Object.keys

      The function that retrieves the keys of the object.

        • (obj): Iterable<string>
        • Parameters

          • obj: Record<string, T>

          Returns Iterable<string>

    Returns Record<string, T>

    A new object with the keys mapped.

    Example

    const object = { a: 1, b: 2, c: 3 };
    const callback = (key: string, value: number) => key.toUpperCase();
    objMapKeys(object, callback);
    //=> { A: 1, B: 2, C: 3 }

Generated using TypeDoc