Implement a String Truncation Utility with Ellipsis and Word-Boundary Awareness
Write a truncate(str, maxLength, options) function that shortens a string to a given maximum character length and appends a suffix (default '...'). Support two modes: hard truncation (cut exactly at maxLength) and word-boundary truncation (cut at the last complete word before the limit to avoid breaking mid-word). Also handle cases where the suffix itself is longer than maxLength. Used in card UIs, tooltips, and text preview components.