manifold/web/lib/util/local.ts
2022-05-25 22:30:03 -07:00

12 lines
245 B
TypeScript

export const safeLocalStorage = () => (isLocalStorage() ? localStorage : null)
const isLocalStorage = () => {
try {
localStorage.getItem('test')
localStorage.setItem('hi', 'mom')
return true
} catch (e) {
return false
}
}