typedash
Version:
modern, type-safe collection of utility functions
17 lines (15 loc) • 733 B
JavaScript
import { t as objectEntries } from "./objectEntries-D0fnOPZh.js";
import { t as objectFromEntries } from "./objectFromEntries-9X94Rk5A.js";
//#region src/functions/mapKeys/mapKeys.ts
/**
* Returns a new object with the same values as the given object, but with each key mapped to a new key as returned by the given mapper function.
* @param object The object to map the keys of.
* @param mapperFunction The function to map the keys with.
* @returns A new object with the mapped keys.
*/
function mapKeys(object, mapperFunction) {
return objectFromEntries(objectEntries(object).map(([key, value]) => [mapperFunction(key, value, object), value]));
}
//#endregion
export { mapKeys as t };
//# sourceMappingURL=mapKeys-DIkDyMCw.js.map