Last active
June 9, 2024 18:02
-
-
Save zsteva/83eea80008ef3aac4803a0c9afb87028 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 symbol_set = Symbol("set"); | |
export class ArraySet { | |
constructor() { | |
this[symbol_set] = new Set(); | |
} | |
get size() { | |
return this[symbol_set].size; | |
} | |
add(...elements) { | |
this[symbol_set].add(elements.join('-')); | |
} | |
clear() { | |
this[symbol_set].clear(); | |
} | |
has(...elements) { | |
return this[symbol_set].has(elements.join('-')); | |
} | |
*[Symbol.iterator]() { | |
for (let item of this[symbol_set][Symbol.iterator]()) { | |
yield item.split('-'); | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment