README
UI Framework Utils
HTMLCustomElement
Base class for Emarsys UI webcomponents.
formatNumber
Utility function for formatting numbers.
Syntax:
formatNumber(options)(value);
formatNumber(options, value);
If multiple values are formatted with the same options, it is more performant to first create a formatter with the options and then reuse it for formatting the values.
Parameters
options
options.style
: Can bedecimal
,percent
orcurrency
. Default:decimal
options.precision
: When a natural number is given, it specifies a fix precision. If-1
is given, all valuable decimals are kept. Default:0
options.trimFractionZeros
: Trim fraction zeros after applying precision. Default:false
options.currency
: Specifies the currency to be used whenoptions.style
iscurrency
. Known currency codes are converted to symbols. Default:EUR
.options.humanize
: If set, the number will be converted to the given unit. Can beauto
,k
,m
,b
ott
. Whenauto
is given, the most meaningful unit will be used.options.language
: Specifies the language of units when humanize is set. Can been
,de
,es
,fr
,ru
,tr
orcn
. Default:en
.
value
: The number which will be formatted.
formatDuration
Utility function for formatting durations.
Syntax:
formatDuration(value, options);
Parameters
value
: The number which will be formatted, interpreted as number of seconds, can be eitherNumber
orString
.options
: Object of options to override default behavior, optional. Unset options will use their default value.pad
: Specifies whether to pad values to fix length. Can betrue
orfalse
. Default:false
.showZeroParts
: Specifies whether to show zero parts if there are non-zero parts as well. Default:false
.precision
: Specifies detail to show. Either smallest unit to show, e.g.minutes
orauto
. Whenauto
is given, the highest non-zero unit and the next will be shown. Default:seconds
.language
: Specifies language to localize unit abbreviations. Can been
,de
,es
,fr
,ru
,tr
orcn
. Default:en
.