Skip to content

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

@sullvn

Description

@sullvn

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions