UNPKG

@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.

31 lines (27 loc) 812 B
/*! * ==================================================== * Rzl Utils-JS. * ---------------------------------------------------- * Version: 3.11.0. * Author: Rizalvin Dwiky. * Repository: https://github.com/rzl-zone/utils-js. * ==================================================== */ 'use strict'; var chunkSYHPSOUU_cjs = require('./chunk-SYHPSOUU.cjs'); var normalizeSpaces = (value, options = { withTrim: true, trimOnly: false }) => { if (!chunkSYHPSOUU_cjs.isNonEmptyString(value)) return ""; if (!chunkSYHPSOUU_cjs.isPlainObject(options)) { options = {}; } const { trimOnly = false, withTrim = true } = options; if (trimOnly) return value.trim(); if (withTrim) { value = value.trim(); } return value.replace(/\s+/g, " "); }; exports.normalizeSpaces = normalizeSpaces;