Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow excluding wordlists when building for browserify #105

Merged
merged 3 commits into from Apr 2, 2019

Conversation

junderw
Copy link
Member

@junderw junderw commented Mar 26, 2019

This will help when packaging bip39 to keep file size down.

With all wordlists: 391392 bytes uglified / compressed.

With English only: 249920 bytes

That saves 141472 bytes

@junderw junderw requested a review from d-yokoi March 26, 2019 03:06
@junderw
Copy link
Member Author

junderw commented Mar 26, 2019

This is the TS version of #98

@junderw junderw mentioned this pull request Mar 26, 2019
5 tasks
_default = require('./wordlists/english.json');
wordlists.english = _default as string[];
wordlists.EN = _default as string[];
} catch (err) {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be even better if you implement this using loop.

};
export function setDefaultWordlist(language: string): void {
const result = wordlists[language];
if (result) DEFAULT_WORDLIST = result;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I expect this function to throw error if the wordlist does not exist.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In addition, why don't we provide getDefaultWordlist as well.

}

export function getDefaultWordlist(): string {
if (!DEFAULT_WORDLIST) throw new Error('No Default Wordlist set');
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this should just return null...?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think undefined is fine.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't you export DEFAULT_LANGUAGE from _wordlists.ts and use it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do you mean?

@junderw junderw merged commit 68d0bb4 into typescript Apr 2, 2019
@junderw junderw mentioned this pull request Apr 2, 2019
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants