UNPKG

@simongrasinovski/str-utils

Version:

A lightweight utility library for effortless string manipulation. Simplify common tasks like case validation, conversion and formatting with easy-to-use functions that enhance your JavaScript applications

23 lines (21 loc) 703 B
"use strict"; var _require = require('./utils'), ensureString = _require.ensureString; var _require2 = require('./constants'), EMPTY_SPACES_REGEX = _require2.EMPTY_SPACES_REGEX; /** * Removes consecutive spaces from a string. * * @function * @param {string} input - The string to process. * @returns {string} String with stripped consecutive spaces. * * @throws {TypeError} Throws an error if the input is not a string. * * @example * const result = removeConsecutiveSpaces('hello world from string utils'); * console.log(result); // 'hello world from string utils' */ module.exports = ensureString(function (input) { return input.replace(EMPTY_SPACES_REGEX, ' '); });