This function converts a set to an array.
JavaScript:
let arrayFromSet = set => [...set];
// Example
console.log(arrayFromSet(new Set([1, 2, 3, 4, 5]))); // [1, 2, 3, 4, 5]
console.log(arrayFromSet(new Set(['a', 'b', 'c']))); // ['a', 'b', 'c']
TypeScript:
let arrayFromSet = (set: Set): T[] => [...set];
// Example
console.log(arrayFromSet(new Set([1, 2, 3, 4, 5]))); // [1, 2, 3, 4, 5]
console.log(arrayFromSet(new Set(['a', 'b', 'c']))); // ['a', 'b', 'c']