Created
November 11, 2020 10:04
-
-
Save davemackintosh/4fe4a9868434712857f2a541d7612db8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const config = { | |
"e02c2064-d961-4feb-lll4-558e0dd596d1": { | |
user: { | |
name: "Ian", | |
}, | |
}, | |
"f662b7aa-e2ff-4406-97c3-c0c6cb511159": { | |
user: { | |
name: "Greg", | |
}, | |
}, | |
"ce0699ad-3578-47d6-837c-2aaad02f4b4a": { | |
user: { | |
name: "Sandra", | |
}, | |
}, | |
}; | |
function inConfig(inConfigKey) { | |
return new (class { | |
valueOf() { | |
return inConfigKey; | |
} | |
toString() { | |
return inConfigKey; | |
} | |
get name() { | |
return config[this.toString()].user.name; | |
} | |
})(); | |
} | |
const key = inConfig("e02c2064-d961-4feb-b8e4-558e0dd596d1"); | |
console.log("Key: %s", key); | |
console.log("Name: %s", key.name); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment