Tweakr
    Preparing search index...

    Function collapseWhitespace

    • Collapses multiple consecutive whitespace characters in a string into a single space and trims leading and trailing whitespace.

      Parameters

      • str: string

        The input string.

      Returns string

      The normalized string with collapsed whitespace.

      1.1.0

      collapseWhitespace("  Hello   World  "); // "Hello World"
      collapseWhitespace("Line\nBreak\tTest"); // "Line Break Test"