Add ExtensionStore (from @polkadot/extension) (#142)

* Add ExtensionStore (from @polkadot/extension)

* Consistent naming, untested/unused File store

* Update File.ts
This commit is contained in:
Jaco Greeff
2019-06-06 18:13:28 +02:00
committed by GitHub
parent abb94d254c
commit da84d5a8ae
9 changed files with 163 additions and 8 deletions
+29
View File
@@ -0,0 +1,29 @@
// Copyright 2017-2019 @polkadot/ui-keyring authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { KeyringStore } from '../types';
import store from 'store';
export default class BrowserStore implements KeyringStore {
all (cb: (key: string, value: any) => void): void {
store.each((value: any, key: string) =>
cb(key, value)
);
}
get (key: string, cb: (value: any) => void): void {
cb(store.get(key));
}
remove (key: string, cb?: () => void): void {
store.remove(key);
cb && cb();
}
set (key: string, value: any, cb?: () => void): void {
store.set(key, value);
cb && cb();
}
}