text wrapped at maxWidth and cut to maxLines, the last kept line ending in an ellipsis when something was dropped. Words are not split unless one alone is wider than a line.
text
maxWidth
maxLines
import { truncateLines } from '@datamoc/mwg/two-d/ui';const width = (text: string) => text.length * 10;console.log(truncateLines('build a bridge across the river gorge', 120, 2, width));// ['build a', 'bridge acr…'] Copy
import { truncateLines } from '@datamoc/mwg/two-d/ui';const width = (text: string) => text.length * 10;console.log(truncateLines('build a bridge across the river gorge', 120, 2, width));// ['build a', 'bridge acr…']
textwrapped atmaxWidthand cut tomaxLines, the last kept line ending in an ellipsis when something was dropped. Words are not split unless one alone is wider than a line.