Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- export interface Storage {
- getItem: (key: string) => string | null
- setItem: (key: string, value: string) => void
- removeItem: (key: string) => void
- }
- const fallback: Storage = {
- getItem: (key: string): string | null => {
- console.log(`This is fallback key "${key}" cannot be readed`)
- return null
- },
- setItem: (key: string, value: string): void => {
- console.log(`This is fallback key "${key}" with value "${value}" cannot be writen`)
- },
- removeItem: (key: string): void => {
- console.log(`This is fallback key "${key}" cannot be removed`)
- },
- }
- export const localStorage = typeof window !== 'undefined' ? window.localStorage : fallback
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement