Skip to content

Function.normalizeWhitespace

github-actions[bot] edited this page Jul 8, 2026 · 21 revisions

umt / normalizeWhitespace

Function: normalizeWhitespace()

normalizeWhitespace(string_): string

Defined in: String/normalizeWhitespace.ts:10

Collapses consecutive whitespace characters into a single space and trims the result. Unlike deleteSpaces, which removes all whitespace, this keeps words separated by single spaces.

Parameters

string_

string

Input string

Returns

string

String with normalized whitespace

Example

normalizeWhitespace("  hello   world \t\n foo "); // "hello world foo"

API

Classes

Interfaces

Type Aliases

Variables

Functions

Clone this wiki locally