Show:

ia.Formatter Class

Module: ia

Provides functions for formatting numbers and strings.

Constructor

ia.Formatter

()

Methods

format

(
  • value
  • precision
)
String | Number

Formats a given string or number.

Parameters:

  • value String | Number

    The value.

  • precision Number

    Number of decimals. Uses the default precision if no argument is passed in.

Returns:

String | Number: The formatted value.

formatNumber

(
  • value
  • precision
)
Number

Get a suitably formatted number.

Parameters:

  • value Number

    A number.

  • precision Number

    Number of decimals. Uses the default precision if no argument is passed in.

Returns:

Number: A number formatted for the current locale, for example 1.2 would be formatted as 1.2 in English, but 1,2 in EspaƱol. If the argument passed in is NOT a number, it is returned unchanged.

formatText

(
  • txt
)
String

Get a suitably formatted string.

Parameters:

  • txt String

    A string.

Returns:

String: A string formatted for the current locale.

unformat

(
  • formattedValue
)
Number

Unformats a given string back to its number.

Parameters:

  • formattedValue String

    The formatted value.

Returns:

Number: The value.

Properties

decimalSeparatorTo

String

The decimal separator

Default: "."

language

String

The language.

Default: "en"

noDataValue

String

The no data value.

Default: "No Data"

precision

Number

The precision.

thousandsSeparatorTo

String

The thousands separator

Default: ","