UNPKG

@pkt/utils

Version:

52 lines (51 loc) 1.21 kB
/** * 剔除字符串中所有空格及换行 * * @param str 字符串 */ export declare function trimAll(str?: string): string; /** * * 字符串插入变量值 * * interpolate('Hello {0}',['World']); // -> Hello World * * interpolate('Hello{0}',['World']); // -> HelloWorld * * @param text 文本 * @param params 参数 * @returns string */ export declare function interpolate(text: string, params: string[]): string; /** * * 查找并替换一个字符串 * * Example * * replaceAll('This is a test string', 'is', 'X') = 'ThX X a test string' * * @returns */ export declare function replaceAll(str: string, search: string, replacement: string): string; /** * * 截断字符串 * * @param str 字符串 * @param maxLength 最大长度 * @returns string */ export declare function truncateString(str: string, maxLength: number): string; /** * * 截断字符串带后缀 * * @param str 字符串 * @param maxLength 最大长度 * @param postfix 后缀(默认...) * @returns */ export declare function truncateStringWithPostfix(str: string, maxLength: number, postfix?: string): string; /** 字符串翻转 */ export declare function reverseStr(str: string): string;