UNPKG

everyutil

Version:

A comprehensive library of lightweight, reusable utility functions for JavaScript and TypeScript, designed to streamline common programming tasks such as string manipulation, array processing, date handling, and more.

17 lines (16 loc) 500 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.collapseWhitespace = void 0; /** * Collapses multiple spaces and newlines into a single space. * * Example: collapseWhitespace("a b\n\nc") → "a b c" * * @author @dailker * @param {string} str - The input string. * @returns {string} The collapsed string. */ function collapseWhitespace(str) { return str.replace(/\s+/g, ' ').trim(); } exports.collapseWhitespace = collapseWhitespace;