25 lines
374 B
JavaScript
25 lines
374 B
JavaScript
|
|
export class Memory {
|
||
|
|
|
||
|
|
constructor(scopeName = "") {
|
||
|
|
this.scopeName = scopeName;
|
||
|
|
this._map = new Map();
|
||
|
|
}
|
||
|
|
|
||
|
|
set(name, value) {
|
||
|
|
this._map.set(name, value);
|
||
|
|
this[name] = value; // property access
|
||
|
|
}
|
||
|
|
|
||
|
|
get(name) {
|
||
|
|
return this._map.get(name);
|
||
|
|
}
|
||
|
|
|
||
|
|
has(name) {
|
||
|
|
return this._map.has(name);
|
||
|
|
}
|
||
|
|
|
||
|
|
delete(name) {
|
||
|
|
this._map.delete(name);
|
||
|
|
delete this[name];
|
||
|
|
}
|
||
|
|
}
|