formatArray
FitFileViewer - API Documentation v30.0.1
FitFileViewer - API Documentation / utils/formatting/formatters/formatUtils / formatArray
Function: formatArray()
formatArray<
T>(val:T,digits?:2,options?:FormatArrayOptions|null|undefined):string|T
Defined in: utils/formatting/formatters/formatUtils.ts:35
Formats an array or a comma-separated string of numbers.
Arrays are rounded and then parsed back to numbers before joining, preserving
the legacy behavior that removes trailing zeroes. Comma-separated strings use
toFixed, preserving fixed decimal places.
Type Parametersβ
Tβ
T
Parametersβ
valβ
T
Value to format.
digits?β
2 = FORMATTING_CONSTANTS.DEFAULT_DECIMAL_DIGITS
Decimal digits to use for numeric values.
options?β
FormatArrayOptions | null | undefined
Formatting options.
Returnsβ
string | T
Formatted values, or the original value when it is not processable.
Exampleβ
FormatArray([1.234, 2.567]); // "1.23, 2.57"
formatArray("1.234,2.567", 1); // "1.2, 2.6"
Throwsβ
Error when strict validation is enabled and a value is invalid.