let state ; export enum EIndexedDBState { NO_ACCESS = 1 , NOT_SUPPORTED = 2 , OK = 3 } export async function getIndexedDBState ( ) { if ( ! state ) { if ( window . indexedDB ) { const openSuccess = await new Promise ( ( resolve ) => { const openRequest = indexedDB . open ( 'test:indexeddb' ) ; openRequest . onerror = ( err ) => resolve ( false ) ; openRequest . onsuccess = ( ) => { openRequest . result . close ( ) ; resolve ( true ) ; } ; } ) ; if ( openSuccess ) { state = EIndexedDBState . OK ; } else { state = EIndexedDBState . NO_ACCESS ; } } else { state = EIndexedDBState . NOT_SUPPORTED ; } } return state ; }