idb-managed
Version:
Easy APIs for IndexedDB, with DB manager to manage local DBs. Based on idb.
24 lines (23 loc) • 586 B
text/typescript
/**
* @file IndexedDB compatibility checker
*/
export default function(): void {
if (!window) {
throw new Error('idb-managed can not run in non-browser environment');
}
for (const property of [
'indexedDB',
'IDBDatabase',
'IDBObjectStore',
'IDBTransaction',
'IDBIndex',
'IDBCursor',
'IDBKeyRange',
'IDBRequest'
]) {
// @ts-ignore
if (!window.hasOwnProperty(property) || !window[property]) {
throw new Error(`${property} is not supported in window`);
}
}
}