textConvert
    Preparing search index...

    Function normalizeWhitespace

    • Collapses runs of whitespace (spaces, tabs, newlines) into a single space, and trims the result.

      Parameters

      • text: string

        Text to normalize.

      Returns string

      The text with whitespace runs collapsed to single spaces and the ends trimmed.

      normalizeWhitespace('  Hello   World  \n\n'); // 'Hello World'