Constructor.
the desired locale
Private
#decimalPrivate
#formatPrivate
#groupPrivate
#indexPrivate
#localePrivate
#numeralGet the locale.
Format a number into a string.
This will return "NaN"
if n
is NaN
or an empty string if n
is undefined
or null
.
Otherwise, n
will be formatted with format
if provided, falling back to
a format with DEFAULT_FORMAT_OPTIONS.
the number to format
Optional
format: NumberFormatthe format to use, or else a default format will be used
the formatted number
Static
forGet a parser for a given locale.
This method will instantiate and cache parsers, returning cached instances if already avaialble.
the locale of the parser to get
the parser
Generated using TypeDoc
A locale-specific number parser.
Remarks
This parser supports basic language parsing abilities, but can still parse unexpected results given the right input. For example:
That example produces
123
instead of the (perhaps?) expected1.23
because.
is a thousands delimiter character in German and the parser simply removes that from the input, resulting in the string"123"
that is then parsed into the number result123
.Adapted from Mike Bostock's lovely code (thanks, Mike!).