Skip to content
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

Access to unit list #48

Closed
phrozen opened this issue Aug 20, 2015 · 4 comments
Closed

Access to unit list #48

phrozen opened this issue Aug 20, 2015 · 4 comments

Comments

@phrozen
Copy link

phrozen commented Aug 20, 2015

Hi, I'm using this awesome library for a project and although there exist a way to get the "well-known kinds" it is useless to me without having a way to obtain the unit list in that category (to put in a select widget or something), the code already has the list, it is just a matter of exposing it and maybe filtering it.

Thoughts?

@gentooboontoo
Copy link
Owner

Could something like what was proposed in PR #14 fit your need?

getUnits("radiation") -> [["Gy","gray","grays"],["R","roentgen"], ...]

Each unit would be grouped by alias.

Side questions, would you display every alias or arbitrarily one of them? How will you filter out unneeded units like light years or astronomical units from length kind for instance?

@phrozen
Copy link
Author

phrozen commented Aug 21, 2015

That would be great!! Is that commit on master?

I guess one way to select them is either take the SI canonical form or the full name (either m or meter, N or Netwon) I would have to check once I have the list via getUnits() and maybe select (Hopefully) alias[0].

I might not need to filter out some units, but in case I would, I would use a dictionary build after having access to the units by kind, and filter them like that. Thanks!

@lukelaws
Copy link
Contributor

Hi there,
I have a need for this as well. And using it in a select box is also my intention. I read over PR #14 and I agree getting the available units of a particular kind is a separate concern from getting aliases. Would it be acceptable to use the key names in UNITS as a single name for each? This is working well for my application: 398ad8f

vsmalladi added a commit to vsmalladi/js-quantities that referenced this issue Oct 4, 2015
gentooboontoo added a commit that referenced this issue Oct 14, 2015
Add getUnits and getAliases 

Addresses #48
@gentooboontoo
Copy link
Owner

Fixed by #53

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants