-
Notifications
You must be signed in to change notification settings - Fork 448
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
Conversation
This is the TS version of #98 |
ts_src/_wordlists.ts
Outdated
_default = require('./wordlists/english.json'); | ||
wordlists.english = _default as string[]; | ||
wordlists.EN = _default as string[]; | ||
} catch (err) {} |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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'); |
There was a problem hiding this comment.
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...?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what do you mean?
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