import { Nullable } from "../types/utils.js"; //#region src/modules/string.d.ts /** * 传入字符串,返回字符串中每个字母不同大小写情况的列表 * @param str - 输入字符串 * @returns - 返回列表 * @example * ```ts * console.log(genAllCasesCombination('mb')) * -> [ 'mb', 'mB', 'Mb', 'MB' ] * ``` * @public */ declare function genAllCasesCombination(str: string): string[]; /** * 使用随机数生成uuid * @returns - UUID字符串 * @public */ declare function generateUUID(): string; /** * 生成任意长度的base62随机字符串 * 可以用于生成短链的编码 * @param len - 生成字符串的长度 * @returns - base62随机字符串 * @public */ declare function generateBase62Code(len?: number): string; /** * 模糊匹配字符串,忽略大小写 * @param searchValue - 用于匹配的字符串 * @param targetString - 匹配的目标字符串 * @returns - 是否匹配 * @public */ declare function fuzzyMatch(searchValue: string, targetString: string): boolean; /** * 获取文件扩展名。 * @param filename - 文件名或文件路径。 * @returns 小写的扩展名,不带"."。如果文件没有扩展名,则返回空字符串。 * @public */ declare function getFileExtension(filename: string): string; /** * 以.分割文件名,返回扩展名 * @param fileName - 文件名 * @returns - 文件扩展名 * @public * @deprecated 使用 getFileExtension 代替 */ declare function getFileExt(fileName: string): string; /** * Capitalize the first word of the string * @param str - 输入字符串 * @returns 首字母大写的字符串 * @example * ```ts * capitalize('hello') // -> 'Hello' * capitalize('va va voom') // -> 'Va va voom' * ``` * @public */ declare const capitalize: (str: string) => string; /** * Formats the given string in camel case fashion * @param str - 输入字符串 * @returns 驼峰格式的字符串 * @example * ```ts * camel('hello world') // -> 'helloWorld' * camel('va va-VOOM') // -> 'vaVaVoom' * camel('helloWorld') // -> 'helloWorld' * ``` * @public */ declare const camelCase: (str: string) => string; /** * Formats the given string in snake case fashion * @param str - 输入字符串 * @param options - 配置选项 * @returns 蛇形格式的字符串 * @example * ```ts * snake('hello world') // -> 'hello_world' * snake('va va-VOOM') // -> 'va_va_voom' * snake('helloWord') // -> 'hello_world' * ``` * @public */ declare const snake_case: (str: string, options?: { splitOnNumber?: boolean; }) => string; /** * Formats the given string in dash case fashion * @param str - 输入字符串 * @returns 短横线格式的字符串 * @example * ```ts * dash('hello world') // -> 'hello-world' * dash('va va_VOOM') // -> 'va-va-voom' * dash('helloWord') // -> 'hello-word' * ``` * @public */ declare const dashCase: (str: string) => string; /** * Formats the given string in pascal case fashion * @param str - 输入字符串 * @returns 帕斯卡格式的字符串 * @example * ```ts * pascal('hello world') // -> 'HelloWorld' * pascal('va va boom') // -> 'VaVaBoom' * ``` * @public */ declare const PascalCase: (str: string) => string; /** * 解析模板字符串,并将占位符替换为数据对象中的值。 * @param str - 包含占位符的模板字符串。 * @param data - 一个记录,其键是占位符的名称(不带括号),值是替换内容。 * @param regex - 用于匹配占位符的正则表达式。默认为 /\\\{\\\{(.+?)\\\}\\\}/g,匹配 \{\{placeholder\}\} 格式。 * @returns 替换占位符后的字符串。 * @example * ```ts * const template = "Hello {{name}}, welcome to {{place}}!"; * const data = { name: "World", place: "our app" }; * console.log(parseTemplate(template, data)); * // -> "Hello World, welcome to our app!" * * const customTemplate = "Hi , your id is ."; * const customData = { user: "Alex", id: "123" }; * const customRegex = /<(.+?)>/g; * console.log(parseTemplate(customTemplate, customData, customRegex)); * // -> "Hi Alex, your id is 123." * ``` * @public */ declare const parseTemplate: (str: string, data: Record, regex?: RegExp) => string; /** * 移除字符串两端指定的字符。 * @param str - 需要修剪的原始字符串,可以为 null。 * @param charsToTrim - 一个包含需要移除字符的字符串,默认为空格。这些字符将被视为一个集合,任何在开头或结尾处匹配此集合中字符的实例都将被移除。 * @returns 修剪后的字符串。如果输入字符串为 null 或 undefined,则返回空字符串。 * @example * ```ts * console.log(trim(" hello world ")); // -> "hello world" * console.log(trim("__hello__", "_")); // -> "hello" * console.log(trim("-!-hello-!-", "-!")); // -> "hello" * console.log(trim("/path/to/file/", "/")); // -> "path/to/file" * console.log(trim(null)); // -> "" * ``` * @public */ declare const trim: (str: Nullable, charsToTrim?: string) => string; /** * 移除字符串开头指定的字符。 * @param str - 需要修剪的原始字符串,可以为 null。 * @param charsToTrim - 一个包含需要移除字符的字符串,默认为空格。这些字符将被视为一个集合,任何在开头处匹配此集合中字符的实例都将被移除。 * @returns 从开头修剪后的字符串。如果输入字符串为 null 或 undefined,则返回空字符串。 * @example * ```ts * console.log(trimStart(" hello world ")); // -> "hello world " * console.log(trimStart("__hello__", "_")); // -> "hello__" * console.log(trimStart("-!-hello-!-", "-!")); // -> "hello-!-" * console.log(trimStart("/path/to/file/", "/")); // -> "path/to/file/" * console.log(trimStart(null)); // -> "" * ``` * @public */ declare const trimStart: (str: Nullable, charsToTrim?: string) => string; /** * 移除字符串末尾指定的字符。 * @param str - 需要修剪的原始字符串,可以为 null。 * @param charsToTrim - 一个包含需要移除字符的字符串,默认为空格。这些字符将被视为一个集合,任何在末尾处匹配此集合中字符的实例都将被移除。 * @returns 从末尾修剪后的字符串。如果输入字符串为 null 或 undefined,则返回空字符串。 * @example * ```ts * console.log(trimEnd(" hello world ")); // -> " hello world" * console.log(trimEnd("__hello__", "_")); // -> "__hello" * console.log(trimEnd("-!-hello-!-", "-!")); // -> "-!-hello" * console.log(trimEnd("/path/to/file/", "/")); // -> "/path/to/file" * console.log(trimEnd(null)); // -> "" * ``` * @public */ declare const trimEnd: (str: Nullable, charsToTrim?: string) => string; /** * 移除字符串中指定的前缀 * @param str - 原始字符串 * @param prefix - 需要移除的前缀 * @returns 移除前缀后的字符串,如果原始字符串不以该前缀开头则返回原字符串 * @example * ```ts * console.log(removePrefix("hello world", "hello ")); // -> "world" * console.log(removePrefix("__hello__", "__")); // -> "hello__" * console.log(removePrefix("test", "no")); // -> "test" * console.log(removePrefix(null, "prefix")); // -> "" * ``` * @public */ declare const removePrefix: (str: Nullable, prefix: string) => string; /** * 根据输入的分支数组生成合并路径 * @param branches - 分支名称数组,按照合并顺序排列 * @returns 返回合并路径数组,每个路径包含两个分支名称,表示从第一个分支合并到第二个分支 * @example * ```ts * console.log(generateMergePaths(['dev-xxx', 'dev', 'test'])) * // -> [['dev-xxx','dev'], ['dev','test']] * * console.log(generateMergePaths(['feature', 'dev', 'test', 'prod'])) * // -> [['feature','dev'], ['dev','test'], ['test','prod']] * ``` * @public */ declare function generateMergePaths(branches: string[]): string[][]; /** * 将数字转换为文字表示,支持英文、中文数字以及罗马数字 * @param value - 要转换的数字(仅整数部分会被处理,会对输入进行截断) * @param options - 配置项 * options.system - 转换系统,可选 'english' | 'chinese' | 'roman',默认 'chinese' * options.useAnd - 英文模式下是否使用 “and”,如 one hundred and one(默认 false) * @returns 转换后的文字 * @example * ```ts * numberToText(1994, { system: 'roman' }) // -> 'MCMXCIV' * numberToText(12345, { system: 'english' }) // -> 'twelve thousand three hundred forty-five' * numberToText(10005) // -> '一万零五' * ``` * @public */ declare const numberToText: (value: number, options?: { system?: "roman" | "english" | "chinese"; useAnd?: boolean; }) => string; //#endregion export { PascalCase, camelCase, capitalize, dashCase, fuzzyMatch, genAllCasesCombination, generateBase62Code, generateMergePaths, generateUUID, getFileExt, getFileExtension, numberToText, parseTemplate, removePrefix, snake_case, trim, trimEnd, trimStart };