Issue: Duplicated code and Failure to expand tonnes in mass.ts
Description:
There is a duplication of code in the mass.ts file, specifically in the conversions
array. The expandMacro
method is called twice with the same parameters, resulting in the duplication of conversions and a potential oversight. Additionally, this duplication prevents the proper expansion of units for ton (tonne) measurements.
Steps to Reproduce:
- Go to the
mass.ts
file.
- Locate the
conversions
array.
- Notice that the
expandMacro
method is called twice with the same parameters.
Expected Behavior:
The expandMacro
method should be called only once with the appropriate parameters to avoid duplicated conversions. Furthermore, the expansion of units for ton (tonne) measurements should be included.
Actual Behavior:
The expandMacro
method is called twice with the same parameters, leading to duplicate conversions. As a result, the expansion of units for ton (tonne) measurements is not present in the conversions.
Code Snippet:
const poundInGrams = new BigNumber(4.535_923_7e2);
export const mass: ReadonlyDeep<Family> = {
// ...
conversions: [
{names: ['gram', 'grams'], symbols: ['g'], ratio: 1},
...expandMacro(Macros.si, {names: ['gram', 'grams'], symbols: ['g'], ratio: 1}),
{names: ['tonne', 'tonnes', 'metric ton', 'metric tons'], symbols: ['t'], ratio: 1e6},
...expandMacro(Macros.si, {names: ['gram', 'grams'], symbols: ['g'], ratio: 1}),
// ... other conversions ...
],
};
Proposed Solution:
Remove the duplicated expandMacro
method call at line 20, as it duplicates the conversions already added at line 17. Additionally, modify the second expandMacro call to properly expand the units for ton (tonne) measurements.
Replace method call at line 20
...expandMacro(Macros.si, {names: ['gram', 'grams'], symbols: ['g'], ratio: 1}),
with
...expandMacro(Macros.si, {names: ['tonne', 'tonnes', 'metric ton', 'metric tons'], symbols: ['t'], ratio: 1e6}),