Skip to main content

toStringTruncate

toStringTruncate(value: T) : String for any type T.

Equivalent to toStringTruncate(value, 2000).

toStringTruncate(value: T, maxLength: Number) : String for any type T.

Truncates the string to a specific number of characters instead of raising an error, then use the function toStringTruncate. toStringTruncate applies toString to its argument but truncates the produced string to the given length. If the resulting string has been truncated, "<<TRUNCATED>>" is appended to the resulting string as a suffix.

Here are some examples.

toStringTruncate([1, 2, 3]) -> "[1,2,3]" // Truncates to 2000 characters
toStringTruncate([1, 2, 3], 100) -> "[1,2,3]"
toStringTruncate([1, 2, 3], 2) -> "[1<<TRUNCATED>>"

See also

Types

Functions