Skip to content

字符串工具集 stringUtils

firstUpperCaseAll 所有首字母大写

typescript
/**
 * @description firstUpperCaseAll 所有首字母大写
 * @param {string} str 字符串
 * @return {string}  首字母大写的字符串
 * @example
 * firstUpperCaseAll('hello world') // Hello World
 */

firstUpperCase 第一个首字母大写

typescript
/**
 * @description firstUpperCase 第一个首字母大写
 * @param {string} str 字符串
 * @return {string}  首字母大写的字符串
 * @example
 * firstUpperCase('helloWorld') // HelloWorld
 */

firstLowerCaseAll 所有首字母小写

typescript
/**
 * @description firstLowerCaseAll 所有首字母小写
 * @param {string} str 字符串
 * @return {string}  首字母小写的字符串
 * @example
 * firstLowerCaseAll('Hello World') // hello world
 */

firstLowerCase 首字母小写

typescript
/**
 * @description firstLowerCase 首字母小写
 * @param {string} str 字符串
 * @return {string}  首字母小写的字符串
 * @example
 * firstLowerCase('Hello World') // hello World
 */

humpToLowerCase 大驼峰转小驼峰

typescript
/**
 * @description humpToLowerCase 大驼峰转小驼峰
 * @param {string} str 字符串
 * @returns 小驼峰字符串
 * @example
 * humpToLowerCase('HelloWorld') // helloWorld
 */

humpToKebabCase 驼峰转拼接符

typescript
/**
 * @description humpToKebabCase 驼峰转拼接符
 * @param {string} str 驼峰字符串
 * @returns 拼接符连接的字符串
 * @example
 * humpToKebabCase('helloWorld') // hello_world
 * humpToKebabCase('helloWorld', '-') // hello-world
 * humpToKebabCase('helloWorld', '·') // hello·world
 */

jsonParse 解析 JSON 字符串

typescript
/**
 * @description jsonParse 解析JSON字符串
 * @param {string} str JSON字符串
 * @param {FuxiFunction} callback 如果解析失败,则调用此回调函数 默认直接输出错误
 * @returns {object} 解析后的JSON对象
 * @example
 * jsonParse('{"name": "John", "age": 30}') // {name: 'John', age: 30}
 */

在MIT许可下发布    备案号: 晋ICP备2024051569号-1