@yookue/ts-lang-utils
    Preparing search index...

    Function center

    • 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 undefined | null | string

      a string that centers the given text using placeholder

      David Hsing

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