added entity

This commit is contained in:
Mohammed Ashab Uddin
2020-07-22 10:43:05 +04:00
parent 29db39c642
commit 1535d4cec0
2 changed files with 101 additions and 0 deletions

View File

@@ -0,0 +1,46 @@
class Entity {
constructor(){
this.data = new Map();
this.count = 0;
}
addData(key ,value){
if(!this.isData(key)){
this.data[key] = value;
return true;
}
return false;
}
/**
* check if key exists
* @param {string} key
*/
isData(key){
return this.data[key] != undefined ? true : false;
}
deleteData(key){
if(this.isData(key)){
return delete this.data[key];
}
return false;
}
clearData(){
this.data = new Map();
this.count = 0;
}
getData(key){
if(this.isData(key)){
return this.data[key];
}
return null;
}
}
module.exports.Entity = Entity;