Constructor
new module:caplin/element/formatter/BracketsFormatter()
Formats a negative number into a value with brackets.
BracketsFormatter
is typically used in the XML Renderer Framework, but can be invoked programmatically
as in the following example which evaluates to "(123)":
caplin.element.formatter.BracketsFormatter.format(-123, {})
See module:caplin/element/parser/BracketsParser
for the complementary parser.
- Implements:
Methods
-
format(vValue, mAttributes) → {String}
-
Formats a negative number into a value with brackets. Any form of suffix is assumed to be part of the number and is included in the conversion. Non-negative numeric values are unchanged. For example, "-1.618" and "-2BIL" are converted to "(1.618)" and "(2BIL)" respectively.
Parameters:
Name Type Description vValue
String | Number the number. mAttributes
Map (unused) Returns:
if number is negative, the absolute number surrounded by brackets, otherwise the original number.- Type
- String