Skip to content

Instantly share code, notes, and snippets.

@kornysietsma
Last active November 17, 2022 14:51
Show Gist options
  • Save kornysietsma/9b5978bf82cb8ec88e52162514a52311 to your computer and use it in GitHub Desktop.
Save kornysietsma/9b5978bf82cb8ec88e52162514a52311 to your computer and use it in GitHub Desktop.
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])));
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
@kornysietsma
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment