1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-17 08:43:33 +00:00

replace electron store with lowdb

This commit is contained in:
Kyle Spearrin
2018-05-31 09:07:56 -04:00
parent 98e2e611f8
commit f618c0b5ee
7 changed files with 121 additions and 42 deletions

View File

@@ -1,36 +0,0 @@
import { StorageService } from '../../abstractions/storage.service';
// tslint:disable-next-line
const Store = require('electron-store');
export class ElectronStorageService implements StorageService {
private store: any;
constructor(defaults?: any) {
const storeConfig: any = {
defaults: {} as any,
name: 'data',
};
if (defaults != null) {
storeConfig.defaults = Object.assign({}, storeConfig.defaults, defaults);
}
this.store = new Store(storeConfig);
}
get<T>(key: string): Promise<T> {
const val = this.store.get(key) as T;
return Promise.resolve(val != null ? val : null);
}
save(key: string, obj: any): Promise<any> {
this.store.set(key, obj);
return Promise.resolve();
}
remove(key: string): Promise<any> {
this.store.delete(key);
return Promise.resolve();
}
}