-
Notifications
You must be signed in to change notification settings - Fork 153
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
Wrong padding in toString() function #198
Comments
@macor161 please do! But if you don't have time, please please submit a failing test 👍 |
wow, currently this looks like not padding at all? 🤔 Line 474 in e69c617
|
I submited a pull request with the fix and a test. |
@therightstuff I like the idea of changing the signature, I think it's better than introducing a new function. What do you think of those 2 signatures?: toString(base: number, bytePadding: number);
toString(options: Object); Internally, it would look something like this: toString(base: number | options: Object, [bytePadding: number]) And options would be: base: number = 10
bytePadding: number = 0
padding: number = 0 This keeps the function backward compatible and is easily extendible |
Let me know when you reach a consensus, I will submit a pull request! :) |
I will close this issue as there doesn't seem to be any activity. |
When the length of a number is larger than the requested padding,
toString
will add an unnecessary padding.For example:
Should return
123
but returns0123
.Or
Should return
12345678
but returns000012345678
.A simple fix would be to first check if the length is actually smaller than the requested padding before applying it.
I can submit a pull request to fix this issue.
The text was updated successfully, but these errors were encountered: