From 444128829ae759552429b067d53c5bbddfd5493a Mon Sep 17 00:00:00 2001 From: Tankred Hase Date: Fri, 5 Feb 2016 13:16:42 +0700 Subject: [PATCH] Refactor src/keyring/*.js to use import & export --- src/keyring/index.js | 8 ++++++-- src/keyring/keyring.js | 9 ++++----- src/keyring/localstore.js | 10 ++++------ 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/keyring/index.js b/src/keyring/index.js index 20c52f87..54bea772 100644 --- a/src/keyring/index.js +++ b/src/keyring/index.js @@ -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; diff --git a/src/keyring/keyring.js b/src/keyring/keyring.js index 9968ce4d..6ff70683 100644 --- a/src/keyring/keyring.js +++ b/src/keyring/keyring.js @@ -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()); } diff --git a/src/keyring/localstore.js b/src/keyring/localstore.js index 44a01f0f..d49aa65d 100644 --- a/src/keyring/localstore.js +++ b/src/keyring/localstore.js @@ -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;