Last active
November 17, 2022 14:51
-
-
Save kornysietsma/9b5978bf82cb8ec88e52162514a52311 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 fooMembers = new Set([1,2]); | |
const barMembers = new Set([1,3]); | |
const groups: Map<Set<number>, String> = new Map(); | |
groups.set(fooMembers,"foo"); | |
groups.set(barMembers,"bar"); | |
console.log(groups.get(fooMembers)); | |
console.log(groups.get(new Set([1,2]))); |
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
type MemberId = number; | |
type GroupMembers = Set<MemberId>; | |
type GroupsByMembers = Map<GroupMembers, String>; | |
const fooMembers: GroupMembers = new Set([1,2]); | |
const barMembers: GroupMembers = new Set([1,3]); | |
const groups: GroupsByMembers = new Map(); | |
groups.set(fooMembers,"foo"); | |
groups.set(barMembers,"bar"); | |
console.log(groups.get(fooMembers)); | |
// "foo" | |
console.log(groups.get(new Set([1,2]))); | |
// undefined |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
see Playground Link