Looking to create a custom ArraySet in Typescript that handles arrays as values:
export class ArraySet extends Set<any> {
override add(arr: any): any {
super.add(arr.toString());
}
override has(arr): boolean {
return super.has(arr.toString());
}
}
Is there a way to modify this class to store and return array values?
Current behavior:
const set = new ArraySet()
set.add([1,1])
set.add([2,1])
set.forEach(e => console.log(typeof(e)))
# string
# string
Expected behavior:
const set = new ArraySet()
set.add([1,1])
set.add([2,1])
set.forEach(e => console.log(typeof(e)))
# object # expecting the element to be an array
# object