gentooboontoo / js-quantities

JavaScript library for quantity calculation and unit conversion
http://gentooboontoo.github.io/js-quantities/
MIT License
396 stars 103 forks source link

Pretty unit output #139

Open carlo-quinonez opened 1 year ago

carlo-quinonez commented 1 year ago

How can we generate a pretty quantity (eg.96 °C, 10 µA) from a Qty? js-quantities has an API for formatting output, including specifying custom formatter functions, but this formatting seems to be concerned with the number rather than the unit.

Our team is developing a tool to monitor the health of instruments sold by our customers. Basically, instruments installed at customer site report back low-level telemetry like fan speeds, temperatures, power, etc. We use js-quantities in several places, including in the dashboards (single page webapps) to display the data in a preferred unit. For example, the instruments might transmit a property as 0.001238 amps but we display as 1.2 µA. We use js-quantitites to do the conversion and rounding, and then handle the unit itself in our code.

However, we need to display pretty quanties in more places than one product so we're consider writing a module to handle prettifying the unit. Has a "pretty units" feature ever been for js-quantities? Would a PR be welcomed adding this feature?