UNPKG

typescript-util

Version:

JS/TS 的简单工具

80 lines 2.57 kB
import { StringConstant } from '../constant/StringConstant'; /** * StrTool * @author 冰凝 * @date 2022-09-19 09:43:23 **/ export declare class StrTool extends StringConstant { private static HTTP_ADDRESS; /** * 字符串是空? {@code null | undefined | 全是空格的字符串} 被认为是空 * @param {string} str 待判断字符串 * @return {boolean} */ static isEmpty(str?: string): boolean; /** * 字符串非空? 楼上 {@link #isEmpty} 的取反 * @param {string} str 待判断字符串 * @return {boolean} */ static isNotEmpty(str?: string): boolean; /** * 判断字符串非空 * null, undefined => true * "null", "undefined" => true (不区分大小写) * " " => true * "" => true * " xxx " => false * * 对于非 string 类型, 抛出错误 * @param {string} str 待检查字符串 * @return {boolean} 是否为空? */ static isGenerEmpty(str?: string): boolean; /** * 重复 * @param {string} source * @param {number} size * @return {string} */ static repeat(source: string, size: number): string; /** * 字符串连接 * TODO: 有点问题 * @param {string} separator 分隔符 * @param {string} str 需要连接的字符串的可变参数列表 * @return {string} 最终连接字符串 */ static join(separator: string, ...str: Array<string>): string; /** * 对象形式的字符串连接 * <p> * 例: * <pre> * const query = StrUtil.joinObject('&', {name: 'test', query: 'other', order: true}) * // 输出: name=test$query=other&order=true * console.log(query) * </pre> * * TODO: 有点问题 * * @param {string} separator 每个字符串单元的分隔符 * @param {Record<PropertyKey, any>} o 对象的 一组 key -> value 为一个字符串单元 * @param {string} conn 对象 key value 连接字符串, 默认 {@link #EQUAL} (等号) * @return {string} 最终连接字符 */ static joinObject(separator: string, o: Record<PropertyKey, any>, conn?: string): string; /** * 是HTTP 绝对地址? */ static isAbsoluteAddress(s: string): boolean; /** * 不是 HTTP 绝对地址 */ static notAbsoluteAddress(s: string): boolean; /** * 对象转 HTTP 查询字符串 */ static toQuery(obj: Record<string, any>): string; } //# sourceMappingURL=StrTool.d.ts.map