/
Scope.js
45 lines (34 loc) · 892 Bytes
/
Scope.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import { utils } from '../lib/jsUtils';
class Scope {
constructor(name, context) {
this.name = name;
this.context = context;
if (name === `main`) {
this.id = name;
} else {
this.id = new Array(16).fill(`x`).map(x => utils.createUuid(x)).join(``);
}
this.data = {
comments: [],
discussions: [],
games: [],
giveaways: [],
groups: [],
trades: [],
users: []
};
}
reset(key) {
if (this.data.hasOwnProperty(key)) {
this.data[key] = [];
}
}
get comments() { return this.data.comments; }
get discussions() { return this.data.discussions; }
get games() { return this.data.games; }
get giveaways() { return this.data.giveaways; }
get groups() { return this.data.groups; }
get trades() { return this.data.trades; }
get users() { return this.data.users; }
}
export { Scope };