Refactor src/keyring/*.js to use import & export
This commit is contained in:
parent
acabca9585
commit
444128829a
|
@ -4,5 +4,9 @@
|
||||||
* @see module:keyring/keyring
|
* @see module:keyring/keyring
|
||||||
* @module keyring
|
* @module keyring
|
||||||
*/
|
*/
|
||||||
module.exports = require('./keyring.js');
|
import Keyring from './keyring.js';
|
||||||
module.exports.localstore = require('./localstore.js');
|
|
||||||
|
import localstore from './localstore.js';
|
||||||
|
Keyring.localstore = localstore;
|
||||||
|
|
||||||
|
export default Keyring;
|
||||||
|
|
|
@ -25,9 +25,8 @@
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var keyModule = require('../key.js');
|
import keyModule from '../key.js';
|
||||||
|
import LocalStore from './localstore.js';
|
||||||
module.exports = Keyring;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialization routine for the keyring. This method reads the
|
* Initialization routine for the keyring. This method reads the
|
||||||
|
@ -35,8 +34,8 @@ module.exports = Keyring;
|
||||||
* @constructor
|
* @constructor
|
||||||
* @param {class} [storeHandler] class implementing load() and store() methods
|
* @param {class} [storeHandler] class implementing load() and store() methods
|
||||||
*/
|
*/
|
||||||
function Keyring(storeHandler) {
|
export default function Keyring(storeHandler) {
|
||||||
this.storeHandler = storeHandler || new (require('./localstore.js'))();
|
this.storeHandler = storeHandler || new LocalStore();
|
||||||
this.publicKeys = new KeyArray(this.storeHandler.loadPublic());
|
this.publicKeys = new KeyArray(this.storeHandler.loadPublic());
|
||||||
this.privateKeys = new KeyArray(this.storeHandler.loadPrivate());
|
this.privateKeys = new KeyArray(this.storeHandler.loadPrivate());
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,13 +24,11 @@
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
module.exports = LocalStore;
|
import config from '../config';
|
||||||
|
import keyModule from '../key.js';
|
||||||
|
import util from '../util.js';
|
||||||
|
|
||||||
var config = require('../config'),
|
export default function LocalStore(prefix) {
|
||||||
keyModule = require('../key.js'),
|
|
||||||
util = require('../util.js');
|
|
||||||
|
|
||||||
function LocalStore(prefix) {
|
|
||||||
prefix = prefix || 'openpgp-';
|
prefix = prefix || 'openpgp-';
|
||||||
this.publicKeysItem = prefix + this.publicKeysItem;
|
this.publicKeysItem = prefix + this.publicKeysItem;
|
||||||
this.privateKeysItem = prefix + this.privateKeysItem;
|
this.privateKeysItem = prefix + this.privateKeysItem;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user