@@ -7,6 +7,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// eslint-disable-next-line max-classes-per-file
|
// eslint-disable-next-line max-classes-per-file
|
||||||
|
import { jsonSaveParse } from '@/lib/HelperFunctions.ts';
|
||||||
|
|
||||||
export class Storage {
|
export class Storage {
|
||||||
constructor(private readonly storage: typeof window.localStorage) {}
|
constructor(private readonly storage: typeof window.localStorage) {}
|
||||||
|
|
||||||
@@ -15,11 +17,7 @@ export class Storage {
|
|||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof defaultValue === 'string') {
|
return jsonSaveParse(value) ?? (value as T);
|
||||||
return value as T;
|
|
||||||
}
|
|
||||||
|
|
||||||
return JSON.parse(value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getItem(key: string): string | null {
|
getItem(key: string): string | null {
|
||||||
|
|||||||
Reference in New Issue
Block a user