blob: dc7e88e4b9cf4969a1a312fcbca6528346cb317c (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
class JSONSet {
items = new Set();
constructor(initial) {
if (Array.isArray(initial)) {
initial.map((x) => this.apply_set_function("add", x));
} else {
this.apply_set_function("add", initial);
}
["add", "has", "remove"].forEach(
(f_name) => (this[f_name] = (x) => this.apply_set_function(f_name, x))
);
}
apply_set_function(f_name, x) {
return this.items[f_name](JSON.stringify(x));
}
}
|