This commit is contained in:
parent
39b0160064
commit
2347ecd201
71 changed files with 3779 additions and 1586 deletions
17
src/utils/browser-storage.ts
Normal file
17
src/utils/browser-storage.ts
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
export const readBrowserStorage = (key: string): string | null => {
|
||||
try {
|
||||
return typeof localStorage === 'undefined' ? null : localStorage.getItem(key);
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
export const writeBrowserStorage = (key: string, value: string): void => {
|
||||
try {
|
||||
if (typeof localStorage !== 'undefined') {
|
||||
localStorage.setItem(key, value);
|
||||
}
|
||||
} catch {
|
||||
// Storage can be unavailable in private browsing or embedded contexts.
|
||||
}
|
||||
};
|
||||
Loading…
Reference in a new issue