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

numbro.unformat can't parse custom formats, such as postfixes #764

Open
sullvn opened this issue Jan 16, 2025 · 0 comments
Open

numbro.unformat can't parse custom formats, such as postfixes #764

sullvn opened this issue Jan 16, 2025 · 0 comments

Comments

@sullvn
Copy link

sullvn commented Jan 16, 2025

unformat currently can't parse custom postfixes. And other custom formatting. Even if provided as a format object in the second parameter.

It looks like the format argument is part of the API, but not actually used. It is passed down from unformat eventually into computeUnformattedValue, but is not actually used there.

numbro/src/unformatting.js

Lines 246 to 253 in 0e58867

/**
* Unformat a numbro-generated string to retrieve the original value.
*
* @param {string} inputString - string to unformat
* @param {NumbroFormat} format - format used while generating the inputString
* @return {number}
*/
function unformat(inputString, format) {

Expected

const format = {  postfix: "test" };
const result = numbro.unformat(numbro(90).format(format), format)
expect(result).toBe(90)

Actual

The result is either NaN or undefined.

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

1 participant