/** * 字符串相关的工具函数 * @filename packages/utils/src/utils/StringUtils.ts * @author Mr Prince * @date 2022-12-06 16:56:23 */ /** * 遍历对象所有属性 * 移除左右两边空格 * * @public */ export declare function trim(data: T): T; /** * 不足位补0 * * @public */ export declare function addZero(num: string | number, length?: number): string; /** * 隐藏部分手机号 * * @public */ export declare const hiddenMobile: (mobile: string, hidden?: string) => string; /** * 数字格式化 * 1234 => 1,234 * * @public */ export declare const numFormat: (num: number, delimiter?: string) => string; /** * 首字母大写 */ export declare const capitalize: (str: T) => Capitalize; /** * 首字母小写 */ export declare const uncapitalize: (str: T) => Uncapitalize; /** * 对象转字符串 * 不是为了格式化成json,只是为了可读,可保存 * 会忽略循环引用的属性 * * 1. 如果是字符串,加上标识直接返回 * 2. 如果是undefined 或者 null,改成字符串 * 3. 如果是Error,打印message 和 stack * 4. 如果是Date类型,返回标识和时间戳 * 5. 如果是数组,加上标识,遍历下标,加上length * 6. 如果是对象, 加上标识,遍历属性 * * @public */ export declare const objectToString: (data: any, references?: Set) => string; /** * 是否包含双字节字符 * * @public */ export declare function hasDoubleByteWord(word: string): boolean; /** * 是否包含中文,日文和韩文 * * @public */ export declare function isChineseChar(word: string): boolean; /** * 是否包含全角符号 * * @public */ export declare function isFullwidthChar(word: string): boolean; /** * -xx-xx- 转为 大驼峰命名 * * @public */ export declare const upperCamelCase: (str: string) => string; /** * 判断字符串是否相等 * * @public */ export declare function isEqual(a: string, b: string, options: { ignoreCase?: boolean; }): boolean; /** * manacher 马拉车算法 * * @public * @param str 字符串 * @param prefix 前缀字符,不存在str中 * @param padding 填充字符,不存在str中 * * @returns 最长回文子串的长度 */ export declare const manacher: (str: string, prefix?: string, padding?: string) => string; /** * @public * * 判断字符串是否是回文 */ export declare const isPalindrome: (str: string) => boolean; /** * 是否含有重复字符 * * @public */ export declare function hasRepeatChar(str: string | string[]): boolean; /** * 判断是否是元音字符 * 字符串必须是 'a' | 'e' | 'i' | 'o' | 'u' | 'A' | 'E' | 'I' | 'O' | 'U' */ export declare const isVowel: (ch: string) => boolean; /** * 字符串 转 union */ export declare const unicode: (str: string) => string[]; /** * unicode 转字符数组 */ export declare const ununicode: (code: number[]) => string[]; /** * 检查全字母句 * 包含 a-z 所有字符 * 不区分大小写 */ export declare const checkPangram: (str: string) => boolean;