papandreou / inter

A JavaScript locale library based on information extracted from the Unicode CLDR database
BSD 3-Clause "New" or "Revised" License
21 stars 5 forks source link

makeFileSizeRenderer, always showing size with in GB #13

Open mwoc opened 10 years ago

mwoc commented 10 years ago

For makeFileSizeRenderer, I've got a use case for always showing the size in GB, even though the size might be just a few bytes.

If I were to make a pull request to add such support, would you also like me to rewrite the function so it doesn't use the Function constructor, but just return a normal function instead?

papandreou commented 8 years ago

At present makeFileSizeRenderer doesn't even get i18ned units from CLDR. They're hardcoded because the correct units weren't available when I wrote the first version of it. They are there now (<unit type="digital-{byte,kilobyte,megabyte,gigabyte,terabyte}">), so the first order of business should be to start using them.

And yeah, it was written back in my wild days when performance of seemingly trivial things was more important, so it uses new Function heavily, which is harder to maintain. Also, it's causing trouble with using inter in restrictive runtimes that liken it to eval. I'd be perfectly ok with letting go of it.