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 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 Mar 26, 2019
@junderw

This comment has been minimized.

Copy link
Member Author

junderw commented Mar 26, 2019

This is the TS version of #98

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

This comment has been minimized.

Copy link
@d-yokoi

d-yokoi Mar 26, 2019

Member

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;

This comment has been minimized.

Copy link
@d-yokoi

d-yokoi Mar 26, 2019

Member

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

This comment has been minimized.

Copy link
@d-yokoi

d-yokoi Mar 26, 2019

Member

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

}

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

This comment has been minimized.

Copy link
@junderw

junderw Mar 28, 2019

Author Member

Maybe this should just return null...?

This comment has been minimized.

Copy link
@d-yokoi

d-yokoi Mar 28, 2019

Member

I think undefined is fine.

This comment has been minimized.

Copy link
@d-yokoi

d-yokoi Mar 28, 2019

Member

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

This comment has been minimized.

Copy link
@junderw

junderw Mar 28, 2019

Author Member

what do you mean?

@junderw junderw merged commit 68d0bb4 into typescript Apr 2, 2019
1 check passed
1 check passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@junderw junderw referenced this pull request Apr 2, 2019
2 of 3 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.