Skip to content

formatNumber: only a number is accepted #84

Open
@sergey-be

Description

@sergey-be

formatNumber helper explicitly verifies the type of a value and throws an exception if it's other than number. But Internationalization API Specification doesn't put such a restriction and Intl.NumberFormat().format() function accepts the argument of any type. So the following examples are perfectly legitimate:

const format = new Intl.NumberFormat().format;
format('1234.56'); // ==> 1,234.56
format({valueOf: () => 56789.01}); // ==> 56,789.01
format(new Date()); // ==> 1,476,977,151,388

I would also expect from this helper to accept a value of any type.

Thank you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions