Files
ETAApi/server/src/Shared/Resources/index.js
2024-04-12 12:22:02 -06:00

38 lines
756 B
JavaScript

'use strict';
class SharedResources{
constructor(){
this.dictionary = {};
}
set( key , val ){
this.dictionary[ key ] = val;
}
exists( key ){
return ( this.dictionary[ key ] != undefined );
}
get( key ){
if( ! this.exists( key ) ){
throw new Error( `Key [${key}] not defined!` );
}
return this.dictionary[ key ];
}
try_get( key ){
if( ! this.exists( key ) ){
return null;
}else{
return this.dictionary[ key ];
}
}
remove( key ){
if( this.exists(key) ){
delete this.dictionary[ key ];
}
}
}
module.exports = new SharedResources();