Pass options as { header: options } (create) (#16)

* Pass options as { header: options } (create)

* Actually save... pass linting as a result
This commit is contained in:
Jaco Greeff
2018-12-10 10:29:39 +01:00
committed by GitHub
parent 63495679c0
commit 58aacdaa33
+12 -10
View File
@@ -35,14 +35,14 @@ class KeyringOption implements KeyringOptionInstance {
this.addAccounts(keyring, options); this.addAccounts(keyring, options);
this.addAddresses(keyring, options); this.addAddresses(keyring, options);
options.address = this.linkItems( options.address = this.linkItems({
{ header: 'Addresses', options: options.address }, 'Addresses': options.address,
{ header: 'Recent', options: options.recent } 'Recent': options.recent
); });
options.account = this.linkItems( options.account = this.linkItems({
{ header: 'Accounts', options: options.account }, 'Accounts': options.account,
{ header: 'Development', options: options.testing } 'Development': options.testing
); });
options.all = ([] as KeyringSectionOptions).concat( options.all = ([] as KeyringSectionOptions).concat(
options.account, options.account,
@@ -55,8 +55,10 @@ class KeyringOption implements KeyringOptionInstance {
hasCalledInitOptions = true; hasCalledInitOptions = true;
} }
private linkItems (...items: Array<{ header: string, options: KeyringSectionOptions }>) { private linkItems (items: { [index: string]: KeyringSectionOptions }) {
return items.reduce((result, { header, options }) => { return Object.keys(items).reduce((result, header) => {
const options = items[header];
return result.concat( return result.concat(
options.length options.length
? [this.createOptionHeader(header)] ? [this.createOptionHeader(header)]