-
Notifications
You must be signed in to change notification settings - Fork 57
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
Support single-character units for parsing #60
base: master
Are you sure you want to change the base?
Conversation
Thank you for your pull request. Isn't this already possible like the following? input = '45k'
console.log(bytes(`{input}b`)) Can you elaborate on the purpose of this feature and how it would be used, etc.? |
Sure, but then you're just putting extra parsing logic into your application code.
It just makes the parsing a little more flexible when working with input from different sources. The meaning of the single-character unit is unambiguous, so I don't see why bytes shouldn't accept it gracefully. |
How will it interact with the addition of |
I suspect the least surprising thing to do would be to map it to classic binary units. That would be a breaking change due to the current units switching to metric anyway, so it would probably be part of a bigger refactoring and api change. |
Gotcha. So we should wait on this to land support for the classic binary units first, then add the single letter alias as a mapping to those? This is likely a breaking change already, as folks may be relying on the existing parsing to reject |
/shrug. I have no idea about the current roadmap. I just hacked this into my local copy as part of my current project, and thought it would be generally useful. |
Adds support for parsing single-character units (k, m, g, t, p).