A new frozen (immutable) object which contains a property for each key and value that returns the defiend mapped value.
const enum Animal {
Dog = 0,
Cat = 1,
Butterfly = 2,
Bear = 3
};
// Creates a simple mapping to a string value
const animalFamilyMap = createValueMap<typeof Animal, string>({
Dog: [ Animal.Dog, "Canidae"],
Cat: [ Animal.Cat, "Felidae"],
Butterfly: [ Animal.Butterfly, "Papilionidae"],
Bear: [ Animal.Bear, "Ursidae"]
});
// You end up with an object that maps everything to the name
animalMap.Dog === "Canidae"; // true with typeof animalMap.Dog is "string"
animalMap[0] === "Canidae"; // true with typeof animalMap[0] is "string"
animalMap["Dog"] === "Canidae"; // true with typeof animalMap["Dog"] is "string"
animalMap.Cat === "Felidae"; // true with typeof animalMap.Cat is "string"
animalMap[1] === "Felidae"; // true with typeof animalMap[1] is "string"
animalMap["Cat"] === "Felidae"; // true with typeof animalMap["Cat"] is "string"
Create a map object which contains both the perperty key and value which both map to the requested generic mapValue with a type of V, E[key] => mapValue and E[value] => mapValue.