Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
/* eslint import/no-mutable-exports: 'off' */
import Dexie from '@cliqz-oss/dexie';
import { chrome } from './globals';
import console from '../core/console';
let storage = {};
try {
const db = new Dexie('cliqz-kv-store');
db.version(1).stores({ kv: 'key' });
storage = {
get(key) {
return db.kv.get(key).then(result => result.value);
},
set(key, value) {
return db.kv.put({ key, value });
},
remove(key) {
return db.kv.delete(key);
}
};
} catch (e) {
// unalble to load indexeddb