@rws-framework/client
Version:
This package provides the core client-side framework for Realtime Web Suit (RWS), enabling modular, asynchronous web components, state management, and integration with backend services. It is located in `.dev/client`.
43 lines (32 loc) • 686 B
JavaScript
class Storage {
static _instance;
_loaded = false;
data = {}
static create(){
if(!this._instance){
this._instance = new Storage();
}
return this._instance;
}
}
const _STORAGE = Storage.create();
function get(key){
if(!has(key)){
return null;
}
return _STORAGE.data[key];
}
function getAll(){
return _STORAGE.data;
}
function init(json){
_STORAGE.data = json;
_STORAGE._loaded = true;
}
function has(key){
return Object.keys(_STORAGE.data).includes(key);
}
function isLoaded(){
return _STORAGE._loaded;
}
module.exports = {get, getAll, has, init, isLoaded}