Truncates the given string if it's longer than the given maximum string length.
Syntax
TypeScript
import { truncate } from '@opentf/std'; truncate( str: string, length = 30, omission = '...' ): string;
length must be a non-negative finite integer.
The result never exceeds length: when omission does not fit, it is itself truncated.
Examples
TypeScript
truncate('hi-package', 8) //=> 'hi-pa...' truncate('hi-package', 5, '---') //=> 'hi---' truncate('hi-package', 2) //=> '..'