-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOriginMap.js
More file actions
25 lines (25 loc) · 831 Bytes
/
OriginMap.js
File metadata and controls
25 lines (25 loc) · 831 Bytes
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
export default class OriginMap extends Map {
set(intention) {
if (!super.has(intention.origin))
super.set(intention.origin, new Map());
const origin = super.get(intention.origin);
origin.set(intention.id, intention);
}
delete(intention) {
if (!super.has(intention.origin)) return;
const origin = super.get(intention.origin);
origin.delete(intention.id);
if (origin.size == 0)
super.delete(intention.origin);
}
has(intention) {
const origin = super.get(intention.origin);
if (origin == null) return false;
return origin.has(intention.id);
}
get(intention) {
const origin = super.get(intention.origin);
if (origin == null) return null;
return origin.get(intention.id);
}
};