Skip to content

Commit

Permalink
fix: invert not to invert inherited properties
Browse files Browse the repository at this point in the history
  • Loading branch information
changwoolab committed Jul 16, 2024
1 parent 64b7018 commit 3dd8009
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/object/invert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
export function invert<K extends PropertyKey, V extends PropertyKey>(obj: Record<K, V>): { [key in V]: K } {
const result = {} as { [key in V]: K };

for (const key in obj) {
for (const key of Object.keys(obj)) {
const value = obj[key as K] as V;
result[value] = key;
result[value] = key as K;
}

return result;
Expand Down

0 comments on commit 3dd8009

Please sign in to comment.