12 lines
222 B
TypeScript
12 lines
222 B
TypeScript
|
export const mapKeys = (
|
||
|
obj: object,
|
||
|
mapper: ( value: unknown, key: string ) => string
|
||
|
) =>
|
||
|
Object.entries( obj ).reduce(
|
||
|
( acc, [ key, value ] ) => ( {
|
||
|
...acc,
|
||
|
[ mapper( value, key ) ]: value,
|
||
|
} ),
|
||
|
{}
|
||
|
);
|