Files
Custom-Static-Website-Gener…/whatsapp-web.js/src/models/entity.js
Mohammed Ashab Uddin e71e9f372b fixed entity map problems
2020-07-28 10:44:40 +04:00

51 lines
847 B
JavaScript

class Entity {
constructor(){
this.data = new Map();
this.count = 0;
}
addData(key ,value){
if(!this.isData(key)){
this.data.set(key, value);
return true;
}
return false;
}
/**
* check if key exists
* @param {string} key
*/
isData(key){
return this.data.has(key) ? true : false;
}
deleteData(key){
if(this.isData(key)){
this.data.delete(key);
return true;
}
return false;
}
clearData(){
this.data = new Map();
this.count = 0;
}
getData(key){
if(this.isData(key)){
return this.data.get(key);
}
return null;
}
getAllData(){
return this.data;
}
}
module.exports.Entity = Entity;