Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Format with abbreviations not work #675

Open
minikinl opened this issue May 12, 2023 · 1 comment
Open

Format with abbreviations not work #675

minikinl opened this issue May 12, 2023 · 1 comment

Comments

@minikinl
Copy link

minikinl commented May 12, 2023

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:

abbreviations: validAbbreviations,

There is an option named abbreviations which can be used in config abbr of thousand | million | ....

Debug

image

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),
@BenjaminVanRyseghem
Copy link
Owner

Thanks for the report. I'll look into it as soon as I can 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants