hd-utils
Version:
A handy utils for modern JS developers
10 lines (9 loc) • 542 B
TypeScript
export type TransformCallback = <K extends string>(key: K, value: K) => [string, string];
/**
* @description function returns an object with keys as the same keys and values as the stringified keys.
* @example createMirroredObject(["a", "b"]); //{ a: "a", b: "b" }
* @example createMirroredObject(["a", "b"], (key, value) => [key.toUpperCase(), value]); // { A: "a", B: "b" }
*/
export default function createMirroredObject<T extends string[]>(keysArray: [...T], transformCallback?: TransformCallback): {
[K in T[number]]: string;
};