manifold/web/lib/util/local.ts

12 lines
245 B
TypeScript
Raw Permalink Normal View History

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