Even though I am capable of
const set = new Set(map.keys())
I don't want to have to rebuild the set. Additionally, I prefer not to create a duplicate set for the return value. The function responsible for returning this set should also have the ability to construct the set from arrays. This means that the returned object must have a similar structure as a set. I require the set in order to check if another input value exists within it and I need to eventually convert the set into an array, like this:
if (set.has(val)) doSomething();
// assign list somewhere
const list = [...set]
Thus, I am seeking an efficient method to convert map keys into a set.