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
Remove dependency on bignumber #6
base: master
Are you sure you want to change the base?
Conversation
}) | ||
|
||
Units.units = rawUnits | ||
|
||
// add leading zeroes | ||
// FIXME: improve | ||
function zeroes (n) { |
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.
you could replace this with return Array(n).fill(0).join('')
but i don't know if that is more or less efficient
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.
you can preallocate big enough zero string and then just do zeros.slice(0, n)
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.
or you can use https://www.npmjs.com/package/left-pad :)
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.
you can preallocate big enough zero string and then just do zeros.slice(0, n)
I was thinking about this, zeroes
would need to be either 31 zeroes (256bits) or the largest in units.json. Any quick way to find the largest unit in units.json
?
or you can use https://www.npmjs.com/package/left-pad :)
I think I leave left-pad alone :)
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 was thinking about this, zeroes would need to be either 31 zeroes (256bits) or the largest in units.json. Any quick way to find the largest unit in units.json?
Sorry, not familiar with ethereum units.. maybe 256-characters length string will be enough? :)
so is this ready to merge? |
Checked against more tests and found that on certain cases it leaves a trailing Need to check why. |
Fixes #3