@rzl-zone/utils-js
Version:
A modern, lightweight set of JavaScript utility functions with TypeScript support for everyday development, crafted to enhance code readability and maintainability.
29 lines (26 loc) • 760 B
JavaScript
/*!
* ====================================================
* Rzl Utils-JS.
* ----------------------------------------------------
* Version: 3.11.0.
* Author: Rizalvin Dwiky.
* Repository: https://github.com/rzl-zone/utils-js.
* ====================================================
*/
import { isNonEmptyString, isPlainObject } from './chunk-MSUW5VHZ.js';
var normalizeSpaces = (value, options = {
withTrim: true,
trimOnly: false
}) => {
if (!isNonEmptyString(value)) return "";
if (!isPlainObject(options)) {
options = {};
}
const { trimOnly = false, withTrim = true } = options;
if (trimOnly) return value.trim();
if (withTrim) {
value = value.trim();
}
return value.replace(/\s+/g, " ");
};
export { normalizeSpaces };