Skip to content

Commit

Permalink
Merge pull request #8 from hckrnews/feature/first-draft
Browse files Browse the repository at this point in the history
Cleanup the inverse
  • Loading branch information
w3nl authored Oct 5, 2021
2 parents baf6f2a + d969b27 commit 1f30d18
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@hckrnews/enum",
"description": "Create vanilla JavaScript enums",
"version": "1.3.1",
"version": "1.3.2",
"author": {
"name": "Pieter Wigboldus",
"url": "https://hckr.news/"
Expand Down
7 changes: 4 additions & 3 deletions src/enum.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ export default class Enum {
}

get invertedOptions () {
return Object
.entries(this.constructor)
.reduce((newObj, [key, value]) => ({ ...newObj, [value]: key }), {})
return Object.fromEntries(
Object.entries(this.constructor)
.map(([key, value]) => [value, key])
)
}

setKey (key) {
Expand Down

0 comments on commit 1f30d18

Please sign in to comment.