mwg API
    Preparing search index...

    Function truncateLines

    • 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.

      Parameters

      • text: string
      • maxWidth: number
      • maxLines: number
      • measure: (text: string) => number
      • ellipsis: string = '…'

      Returns string[]

      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…']