Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async get(cls: T | StorableConstructor, id: string) {
const s = cls instanceof Storable ? cls : new cls();
const data = await localStorage.getItem(`${s.kind}_${id}`);
if (!data) {
throw new Err(ErrorCode.NOT_FOUND);
}
return s.fromRaw(data);
}
async getCache(key, compressed) {
const data = await localForage.getItem(key + (compressed ? '' : '-raw'));
return data ? (compressed ? decompress(data) : data) : null;
}
async get(cls: T | StorableConstructor, id: string) {
const s = cls instanceof Storable ? cls : new cls();
const data = await localStorage.getItem(`${s.kind}_${id}`);
if (!data) {
throw new Err(ErrorCode.NOT_FOUND);
}
return s.fromRaw(data);
}