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
* @module keyring
*/
module.exports = require('./keyring.js');
module.exports.localstore = require('./localstore.js');
import Keyring from './keyring.js';
import localstore from './localstore.js';
Keyring.localstore = localstore;
export default Keyring;

View File

@ -25,9 +25,8 @@
'use strict';
var keyModule = require('../key.js');
module.exports = Keyring;
import keyModule from '../key.js';
import LocalStore from './localstore.js';
/**
* Initialization routine for the keyring. This method reads the
@ -35,8 +34,8 @@ module.exports = Keyring;
* @constructor
* @param {class} [storeHandler] class implementing load() and store() methods
*/
function Keyring(storeHandler) {
this.storeHandler = storeHandler || new (require('./localstore.js'))();
export default function Keyring(storeHandler) {
this.storeHandler = storeHandler || new LocalStore();
this.publicKeys = new KeyArray(this.storeHandler.loadPublic());
this.privateKeys = new KeyArray(this.storeHandler.loadPrivate());
}

View File

@ -24,13 +24,11 @@
'use strict';
module.exports = LocalStore;
import config from '../config';
import keyModule from '../key.js';
import util from '../util.js';
var config = require('../config'),
keyModule = require('../key.js'),
util = require('../util.js');
function LocalStore(prefix) {
export default function LocalStore(prefix) {
prefix = prefix || 'openpgp-';
this.publicKeysItem = prefix + this.publicKeysItem;
this.privateKeysItem = prefix + this.privateKeysItem;