Browse Source

Don't wrap format objects in a map

master
Luke Childs 6 years ago
parent
commit
f3be9710a4
  1. 12
      src/index.js

12
src/index.js

@ -2,22 +2,22 @@ const Emitter = require('tiny-emitter');
const ONE_SECOND = 1000; const ONE_SECOND = 1000;
const keyFormats = new Map(Object.entries({ const keyFormats = {
wif: require('./key-formats/wif'), wif: require('./key-formats/wif'),
bip39: require('./key-formats/bip39') bip39: require('./key-formats/bip39')
})); };
const addressFormats = new Map(Object.entries({ const addressFormats = {
p2pkh: require('./address-formats/p2pkh'), p2pkh: require('./address-formats/p2pkh'),
'p2wpkh-p2sh': require('./address-formats/p2wpkh-p2sh'), 'p2wpkh-p2sh': require('./address-formats/p2wpkh-p2sh'),
p2wpkh: require('./address-formats/p2wpkh') p2wpkh: require('./address-formats/p2wpkh')
})); };
class Vain extends Emitter { class Vain extends Emitter {
constructor({keyFormat = 'wif', addressFormat = 'p2pkh', prefix}) { constructor({keyFormat = 'wif', addressFormat = 'p2pkh', prefix}) {
super(); super();
this.generateKey = keyFormats.get(keyFormat); this.generateKey = keyFormats[keyFormat];
this.addressFormat = addressFormats.get(addressFormat); this.addressFormat = addressFormats[addressFormat];
if (typeof prefix !== 'string' || prefix.length === 0) { if (typeof prefix !== 'string' || prefix.length === 0) {
throw new Error('Prefix must be set'); throw new Error('Prefix must be set');

Loading…
Cancel
Save