• Returns a string that abbreviates the given text using placeholder

    Parameters

    • Optionaltext: null | string

      the text to inspect

    • width: number = -1

      the max width of the expected string

    • placeholder: string = '...'

      the placeholder to append

    Returns string | undefined | null

    a string that abbreviates the given text using placeholder

    abbreviate('foobar', -1);    // 'foobar'
    abbreviate('foobar', 0); // ''
    abbreviate('foobar', 5); // 'fo...'
    abbreviate('foobar', 6); // 'foobar'
    abbreviate('foobar', 10); // 'foobar'