text cut to fit maxWidth, ending in ellipsis, as measured by measure (the width of a string
in whatever font the caller draws it with). A text that already fits comes back unchanged.
Parameters
text: string
maxWidth: number
measure: (text:string)=>number
ellipsis: string = '…'
Returns string
Example
import { ellipsize } from'@datamoc/mwg/two-d/ui';
constwidth = (text: string) =>text.length * 10; console.log(ellipsize('3. Le Fleuve profond (verrouillé)', 150, width)); // 3. Le Fleuve…
textcut to fitmaxWidth, ending inellipsis, as measured bymeasure(the width of a string in whatever font the caller draws it with). A text that already fits comes back unchanged.