jonahsnider / convert

The smallest & fastest library for really easy, totally type-safe unit conversions in TypeScript & JavaScript.
https://convert.js.org
MIT License
124 stars 17 forks source link

Guide on contribution #693

Closed the-e3n closed 1 hour ago

the-e3n commented 2 hours ago

I would like to extend the units that are available in the repo. I saw the repo and found that all units are present in src/conversions/measures. i wanted to know that will it work if i only add the units there or is there anything else i would need to do in order for that to work. @jonahsnider

jonahsnider commented 2 hours ago

Yes, adding any new units to an existing measure should work. Adding a new measure entirely is more difficult as that involves editing a few files.

If this is for adding new units to the package itself, I'm also happy to make that change if you let me know which ones you wanted to see added.

the-e3n commented 2 hours ago

Add these for energy with there macros - btu,therm

BTU - British Thermal Unit 1 BTU - 1055.06 J 1 therm(US Therm) = 29.307107 kWh or 1.055e+8 J 1 MmBTU (Metric Million British Thermal Unit) = 1 Dth (Decatherm) 1 Dth = 10 therms 1 MmBTU = 10 therms 1 MMBTU = 293.07107 kWh 1TR(ton of refrigeration ) = 12000 BTU 1TRh(ton of refrigeration ) = 12000 BTUh

jonahsnider commented 2 hours ago
  • I would like to add an alias to pound as lbs

This can be done, I'll push a new version that adds this soon.

and also the macros for pound as well like kLbs or Mlbs.

I'm not sure this would make a lot of sense since these aren't really standard symbols. Additionally, something like kLbs is very similar to klb, which is a symbol for a kip., which is a measure of force, not mass.

  • Also add ton as a alias for tonne.

The decision to not include ton as a unit/symbol is deliberate, as there is no standardized definition of what a ton is. The Wikipedia page on it says

Ton is any of several units of measure of mass, volume or force. It has a long history and has acquired several meanings and uses.

To avoid confusion from users expecting it to be a US customary ton, metric ton, or something else, I'd prefer to not include this in the library.

Add these for energy with there macros - btu,therm

Similarly, BTUs do not have a standard definition. The Wikipedia page for them has an entire section dedicated just to the different kinds of definitions.

BTUs were requested in #656 where I opted to leave them out from the library for that same reason of reducing confusion/ambiguity.

the-e3n commented 1 hour ago

Ok thanks