kellysutton / ember-number-to-human-size

A simple Ember helper for adding a Rails-inspired number-to-human-size helper
MIT License
6 stars 1 forks source link

Convert value from different units to different units #4

Open onechiporenko opened 7 years ago

onechiporenko commented 7 years ago

Hi, @kellysutton. Thanks for your good addon! Would you be interested in a PR with helper that takes value, its current units and convert it to the another units? Example:

{{number-to-fixed-size 1024 false 0 KB MB}} {{! prints "1 MB" }}
{{number-to-fixed-size 1 false MB KB}} {{! prints "1024 KB" }}

If it is interesting to you let me know - I'll start work on PR. number-to-fixed-size - please select appropriate one. Arguments order may be discussed too.

kellysutton commented 7 years ago

Hi @onechiporenko,

Thanks for the note. I think this is a good idea, but could use some refinement. How about an extra parameter that only takes the target format?

I say this because it seems like most of the time you are dealing with nicely displaying byte counts, you likely have an integer of bytes and probably not something in an already formatted string.

What do you think?

onechiporenko commented 7 years ago

Well, I have case when input units are not always bytes. How about use Bytes as default units and allow user to specify custom one if needed?