• Returns a string that centers 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 pad

    Returns string | undefined | null

    a string that centers the given text using placeholder

    center('foobar', -1);    // 'foobar'
    center('foobar', 0); // ''
    center('foobar', 3); // 'foobar'
    center('foobar', 7); // 'foobar '
    center('foobar', 10); // ' foobar '