Refactor src/keyring/*.js to use import & export

This commit is contained in:
Tankred Hase 2016-02-05 13:16:42 +07:00
parent acabca9585
commit 444128829a
3 changed files with 14 additions and 13 deletions

View File

@ -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;

View File

@ -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());
} }

View File

@ -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;