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:
@@ -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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user