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

How to get a list of best units for a MeasureKind? #720

Open
tworkool opened this issue Jan 21, 2025 · 2 comments
Open

How to get a list of best units for a MeasureKind? #720

tworkool opened this issue Jan 21, 2025 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@tworkool
Copy link

I need a list of best possible units for a specific MeasureKind. The function getMeasureKind is exported, but no function for getting a list of best possible units.

Is there a nice way to achieve this? And if no, maybe it would be a nice feature?

@jonahsnider jonahsnider added the enhancement New feature or request label Jan 22, 2025
@jonahsnider jonahsnider self-assigned this Jan 22, 2025
@jonahsnider
Copy link
Owner

Like you said, the best units aren't currently exported, and I'm open to adding in that functionality, but it should be possible for you to copy over the values convert uses.

Each of the conversion definitions includes a best array/object which you are free to copy over:

best: { metric: ['mm2', 'cm2', 'm2', 'km2'], imperial: ['sq in', 'sq ft', 'ac', 'sq mi'] },

This lets you have total control over which units are included in your app & ensures that if I ever update them on my end, the values in your app are separated (which might be a negative depending on your use case). Does this seem like a reasonable compromise, or should I try and add in a way to programmatically retrieve them?

@tworkool
Copy link
Author

I think it would be a really useful addition. Imagine the scenario where a user of a dashboard wants to display possible conversions for a unit as a measure of convenience (imperial to metric or the other way around).

But for now I will likely stick to your suggestion to extract the types. These units will not change anytime soon 😄.

Thanks

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

No branches or pull requests

2 participants