Skip to content

Commit

Permalink
Add indexedDB check
Browse files Browse the repository at this point in the history
  • Loading branch information
dplewis committed Feb 13, 2021
1 parent 0448254 commit 3494fde
Showing 1 changed file with 24 additions and 20 deletions.
44 changes: 24 additions & 20 deletions src/IndexedDBStorageController.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,29 @@

import { createStore, del, set, get, clear, keys } from 'idb-keyval';

const ParseStore = createStore('parseDB', 'parseStore');
try {
const ParseStore = createStore('parseDB', 'parseStore');

export const IndexedDBStorageController = {
async: 1,
getItemAsync(path: string) {
return get(path, ParseStore);
},
setItemAsync(path: string, value: string) {
return set(path, value, ParseStore);
},
removeItemAsync(path: string) {
return del(path, ParseStore);
},
getAllKeysAsync() {
return keys(ParseStore);
},
clear() {
return clear(ParseStore);
},
};
const IndexedDBStorageController = {
async: 1,
getItemAsync(path: string) {
return get(path, ParseStore);
},
setItemAsync(path: string, value: string) {
return set(path, value, ParseStore);
},
removeItemAsync(path: string) {
return del(path, ParseStore);
},
getAllKeysAsync() {
return keys(ParseStore);
},
clear() {
return clear(ParseStore);
},
};

module.exports = IndexedDBStorageController;
module.exports = IndexedDBStorageController;
} catch (e) {
// IndexedDB not supported
}

0 comments on commit 3494fde

Please sign in to comment.