numbro
numbro copied to clipboard
Format with abbreviations not work
Problem
Run this code at console of numbro website:
numbro(1234000).format({
output: "number",
forceAverage: "million",
abbreviations: {
thousand: "K",
million: "M",
billion: "B",
trillion: "T"
},
})
// output: 1m
Expect Behavior
The outputs should be 1M
Description
According to the description of the code:
https://github.com/BenjaminVanRyseghem/numbro/blob/cac205533ccdb6013a855f6aa6467acd04dae269/src/validating.js#L154
There is an option named abbreviations
which can be used in config abbr of thousand | million | ...
.
Debug
Within the formatting.js#formatNumber()
function,the providedFormat.abbreviations
was ignored to computed the average abbreviation. ONLY globalState.currentAbbreviations
was used.
Solution
// maybe this will work...
abbreviations: Object.assign({}, state.currentAbbreviations(), providedFormat.abbreviations),
Thanks for the report. I'll look into it as soon as I can :smile: