es-toolkit
Version:
A state-of-the-art, high-performance JavaScript utility library with a small bundle size and strong type annotations.
32 lines (31 loc) • 1.31 kB
TypeScript
import { ListIteratee } from "../_internal/ListIteratee.js";
import { ObjectIteratee } from "../_internal/ObjectIteratee.js";
//#region src/compat/object/mapKeys.d.ts
/**
* Creates an object with the same values as `object` and keys generated by running each own enumerable string keyed property through `iteratee`.
*
* @template T
* @param object - The object to iterate over.
* @param [iteratee] - The function invoked per iteration.
* @returns Returns the new mapped object.
*
* @example
* mapKeys([1, 2, 3], (value, index) => `key${index}`);
* // => { 'key0': 1, 'key1': 2, 'key2': 3 }
*/
declare function mapKeys<T>(object: ArrayLike<T> | null | undefined, iteratee?: ListIteratee<T>): Record<string, T>;
/**
* Creates an object with the same values as `object` and keys generated by running each own enumerable string keyed property through `iteratee`.
*
* @template T
* @param object - The object to iterate over.
* @param [iteratee] - The function invoked per iteration.
* @returns Returns the new mapped object.
*
* @example
* mapKeys({ a: 1, b: 2 }, (value, key) => key + value);
* // => { 'a1': 1, 'b2': 2 }
*/
declare function mapKeys<T extends object>(object: T | null | undefined, iteratee?: ObjectIteratee<T>): Record<string, T[keyof T]>;
//#endregion
export { mapKeys };