dividab / uom

Extensible unit of measure conversion with type safety for typescript
MIT License
18 stars 1 forks source link

Naming of unit name concepts #12

Closed jonaskello closed 5 years ago

jonaskello commented 5 years ago

The unit today have several concepts to describe its name/identification:

To clarify what is what we should decide which concepts to keep and always use the same word to describe them.

For the symbol field we can either remove the function to have a fallback and default to blank when there is no registered label for a Unit, or we can rename this field to label.

jonaskello commented 5 years ago

Since we potentially want to move all the registries with global mutable state out of this package, it might be a good idea to keep symbol as-is on BaseUnit and AlternativeUnit and also keep the buildDerivedName function this package and export it for external use (it is a pure function that is not dependent on the registry). The function should be renamed to buildDerivedLabel or buildDerivedSymbol where the latter seems more logical since it uses the symbol field from the BaseUnit to build the result.

jonaskello commented 5 years ago

Since buildDerivedName is a pure function with only Unit as input it makes sense to move that function to the unit.ts module and export it from there (and also rename it to buildDerivedSymbol).