/** * 首字母大写 * * ```ts * import { upperFirstLetter } from 'sunny-js' * console.log(upperFirstLetter('hello')) * // => 'Hello' * ``` * * @see https://flaviocopes.com/how-to-uppercase-first-letter-javascript/ * @category 字符串 */ export declare function upperFirstLetter(string: string): string; /** * 是否为字符串 * @category 字符串 */ export declare function isStr(input: unknown): input is string; /** * 生成一段随机字符串 * * ```ts * import { random } from 'sunny-js' * console.log(random(5)) * ``` * * @param length 随机数长度 * @category 字符串 */ export declare function random(length: number): string; /** * 去除字符串开头的空格字符 * * ```ts * import { trimStart } from 'sunny-js' * console.log(trimStart(' Hello')) * // => 'Hello' * * // 指定匹配模式 * console.log(trimStart('@Hello', '@')) * // => 'Hello' * ``` * * @param str * @param matcher 字符串开头匹配规则,将会转换成正则表达式``RegExp(`^${matcher}+`, 'ig')``。默认匹配空格。 * @category 字符串 */ export declare function trimStart(str?: string, matcher?: string): string; /** * 去除字符串末尾的空格字符 * * ```ts * import { trimEnd } from 'sunny-js' * console.log(trimEnd('Hello ')) * // => 'Hello' * * // 指定匹配模式 * console.log(trimEnd('Hello!', '!')) * // => 'Hello' * ``` * * @param str * @param matcher 字符串末尾匹配规则,将会转换成正则表达式``RegExp(`${matcher}+$`, 'ig')``。默认匹配空格。 * @category 字符串 */ export declare function trimEnd(str?: string, matcher?: string): string; /** * 去除字符串首尾的空格字符 * * ```ts * import { trim } from 'sunny-js' * console.log(trim(' Hello ')) * // => 'Hello' * * // 指定匹配模式 * console.log(trim('/Hello/', '/')) * // => 'Hello' * console.log(trim('(Hello)', '[()]')) * // => 'Hello' * ``` * * @param str * @param matcher 字符串首尾匹配规则,将会转换成正则表达式``RegExp(`^${matcher}+|${matcher}+$`, 'ig')``。默认匹配空格。 * @category 字符串 */ export declare function trim(str?: string, matcher?: string): string; /** * 用来替换npm uuid内应用node核心库crypto导致客户端项目webpack4进行polyfill,以至于 * bundle臃肿的问题 * * @see https://www.npmjs.com/package/uuid * @see https://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid * @returns 返回uuid v4标准的随机字符串 * @category 字符串 */ export declare function uuidV4(): string;