bootstrap-vue-next
Version:
Seamless integration of Vue 3, Bootstrap 5, and TypeScript for modern, type-safe UI development
42 lines (41 loc) • 1.52 kB
JavaScript
import { _ as RX_UNDERSCORE, c as RX_FIRST_START_SPACE_WORD, d as RX_LOWER_UPPER, g as RX_START_SPACE_WORD, m as RX_SPACES, p as RX_REGEXP_REPLACE } from "./constants-BSIK14yA.mjs";
//#region src/utils/stringUtils.ts
/**
* @param str
* @returns
*/
var startCase = (str) => str.replace(RX_UNDERSCORE, " ").replace(RX_LOWER_UPPER, (_, $1, $2) => `${$1} ${$2}`).replace(RX_FIRST_START_SPACE_WORD, (_, $1, $2) => $1 + $2.toUpperCase());
/**
* @param str
* @returns
*/
var titleCase = (str) => str.replace(RX_UNDERSCORE, " ").replace(RX_LOWER_UPPER, (_, $1, $2) => `${$1} ${$2}`).replace(RX_START_SPACE_WORD, (_, $1, $2) => $1 + $2.toUpperCase());
/**
* Uppercases the first letter of a string and returns a new string
*
* @param str
* @returns
*/
var upperFirst = (str) => {
const trim = str.trim();
return trim.charAt(0).toUpperCase() + trim.slice(1);
};
/**
* Escapes a string for RegExp usage.
*
* @param str
* @returns
*/
var escapeRegExp = (str) => str.replace(RX_REGEXP_REPLACE, "\\$&");
/**
* Escapes special chars in string and replaces
* contiguous spaces with a whitespace match
*
* @param str
* @returns
*/
var escapeRegExpChars = (str) => escapeRegExp(str).replace(RX_SPACES, "\\s");
var toPascalCase = (str) => str.replace(/-./g, (match) => match.charAt(1).toUpperCase()).replace(/\b\w/g, (match) => match.toUpperCase()).replace(/\s+/g, "");
//#endregion
export { upperFirst as a, toPascalCase as i, startCase as n, titleCase as r, escapeRegExpChars as t };
//# sourceMappingURL=stringUtils-CslYpDTt.mjs.map