jonahsnider/convert

Cannot get KB, MB, etc. units when using "best" for data conversion

agneslazo opened this issue · 2 comments

When using the "best" parameter for data conversion it always returns the binary unit (KiB, MiB, etc.) for both the "imperial" or "metric" parameter. I think when using the "metric" param, it should be returning MB, GB, etc.

This seems to be a simple change in your bestUnits type for the "metric" kind, was hoping this could be updated.

Thanks!

I am also having a similar issue actually.
I need to convert seconds to the best unit possible, often these units will be ps, fs, or possibly smaller units. But for some reason, it seems the units defined for best for time only goes up to nano seconds (ns).

Maybe I am missing something, but could this not be a pretty easy fix. Hoping this can possibly get updated

Edit:
https://github.com/jonahsnider/convert/blob/master/packages/conversions/src/conversions/time.ts
I can see here that best: ['ns', 'μs', 'ms', 's', 'min', 'h', 'd', 'y'] for time.
This seems to be why .to("best") only returns upto ns.

🎉 This issue has been resolved in version 4.12.0 🎉

The release is available on:

Your semantic-release bot 📦🚀