-
Notifications
You must be signed in to change notification settings - Fork 53
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
Input Upper Case characters = error #14
Comments
+1 |
1 similar comment
+1 |
Fixed in my fork https://github.com/theofidry/bytes.js, waiting for merge. |
I'm confused by this, isn't |
@rhys-vdw technically |
According to Wikipedia, it's As for using But that raises the point of what will happen if you pass a value not understood (like |
I think @tj is correct in that the units that this library deals with are multiples of 1024, so technically 'mb' is interpreted as 'mibibytes'. However, in practise I never hear anyone using that term. I think I'd refer to mibibytes as 'megabytes'. If it's interesting, the reason I suggested this was that I wanted to store the string in a config file, and also forward the error to the user. So: maxFileSize = config.get('maxFileSize');
if (file.size > bytes(maxFileSize)) {
throw new Error('File exceeds maximum size of ' + maxFileSize);
} But I don't want my error message (or config) to have the incorrect units. Obviously there are numerous workarounds for this (simplest being to change cases contextually). I see now that this is really a pretty simple module with limited use cases. Unless you want to expand to handling conversion between different units (bytes, bits, mibibytes, megabytes) @theofidry's solution is probably most appropriate. |
I wouldn't mind support for bits/bytes since network config is typical in bits, but I'd definitely worry about people misconfiguring with different units |
bash >node
The text was updated successfully, but these errors were encountered: