typedash
Version:
modern, type-safe collection of utility functions
22 lines (20 loc) • 880 B
JavaScript
const require_objectEntries = require('./objectEntries-Dx2VL-5Q.cjs');
const require_objectFromEntries = require('./objectFromEntries-CFhk9KlT.cjs');
//#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 require_objectFromEntries.objectFromEntries(require_objectEntries.objectEntries(object).map(([key, value]) => [mapperFunction(key, value, object), value]));
}
//#endregion
Object.defineProperty(exports, 'mapKeys', {
enumerable: true,
get: function () {
return mapKeys;
}
});
//# sourceMappingURL=mapKeys-C059LFk2.cjs.map