UNPKG

t-comm

Version:

专业、稳定、纯粹的工具库

84 lines (83 loc) 1.87 kB
/** * 横线转驼峰命名,如果第一个字符是字母,则不处理。 * @param {string} str 输入字符串 * @param {boolean} handleSnake 是否处理下划线,默认不处理 * @returns {string} 处理后的字符串 * @example * * camelize('ab-cd-ef') * * // => abCdEf * */ export declare function camelize(str?: string, handleSnake?: boolean): string; export declare const toCamel: typeof camelize; /** * 驼峰命名转横线命名:拆分字符串,使用 - 相连,并且转换为小写 * @param {string} str 输入字符串 * @returns {string} 处理后的字符串 * * @example * * hyphenate('abCd') * * // => ab-cd * */ export declare function hyphenate(str: string): string; export declare const toKebab: typeof hyphenate; /** * 字符串首位大写 * @param {string} str 输入字符串 * @returns {string} 处理后的字符串 * * @example * * capitalize('abc') * * // => Abc */ export declare function capitalize(str: string): string; /** * 将每个单词的首字母转换为大写 * @param {string} str 输入字符串 * @returns {string} 处理后的字符串 * * @example * * titleize('my name is yang') * * // My Name Is Yang * * titleize('foo-bar') * * // Foo-Bar */ export declare function titleize(str: string): string; /** * 首字母小写 * @param {string} str 输入字符串 * @returns {string} 输出字符串 * @example * * lowerInitial('GroupId') * * // groupId */ export declare function lowerInitial(str: string): string; /** * 用大驼峰,即 PascalCase 格式,来格式化字符串 * @param str 字符串 * @returns PascalCase 的字符串 * * @example * ```ts * pascalCase('ab-cd') * // AbCd * * pascalCase('ab_cd') * // AbCd * ``` */ export declare function pascalCase(str?: string): string; export declare const toPascal: typeof hyphenate;