function ellipsize(text, width, styles, ellipsizeStr) {
        ellipsizeStr = typeof  ellipsizeStr !== 'undefined' ? ellipsizeStr : '...';

        if (Array.isArray(text)) {
            text.forEach(function (str, i) {
                text[i] = ellipsize(str, width, styles, ellipsizeStr);
            });
            return text;
        }

        if (width >= getStringWidth(text, styles)) {
            return text;
        }
        while (width < getStringWidth(text + ellipsizeStr, styles)) {
            if (text.length < 2) {
                break;
            }
            text = text.substring(0, text.length - 1);
        }
        return text.trim() + ellipsizeStr;
    }
/**
     * Ellipsize the text to fit in the width
     */
Ellipsize the text to fit in the width
Ellipsize the text to fit in the width
function ellipsize(text, width, styles, ellipsizeStr) {
        ellipsizeStr = typeof  ellipsizeStr !== 'undefined' ? ellipsizeStr : '...';
        if (Array.isArray(text)) {
            text.forEach(function (str, i) {
                text[i] = ellipsize(str, width, styles, ellipsizeStr);
            });
            return text;
        }
        if (width >= getStringWidth(text, styles)) {
            return text;
        }
        while (width < getStringWidth(text + ellipsizeStr, styles)) {
            if (text.length < 2) {
                break;
            }
            text = text.substring(0, text.length - 1);
        }
        return text.trim() + ellipsizeStr;
    }
function ellipsize ( text , width , styles , ellipsizeStr ) { ellipsizeStr = typeof ellipsizeStr !== 'undefined' ? ellipsizeStr : '...' ; if ( Array . isArray ( text ) ) { text . forEach ( function ( str , i ) { text [ i ] = ellipsize ( str , width , styles , ellipsizeStr ) ; } ) ; return text ; } if ( width >= getStringWidth ( text , styles ) ) { return text ; } while ( width < getStringWidth ( text + ellipsizeStr , styles ) ) { if ( text . length < 2 ) { break ; } text = text . substring ( 0 , text . length - 1 ) ; } return text . trim ( ) + ellipsizeStr ; }
Ellipsize the text to fit in the width
Ellipsize the text to fit in the width