UNPKG

mihawk

Version:

A tiny & simple mock server tool, support json,js,cjs,ts(typescript).

46 lines (45 loc) 1.61 kB
/** * 模糊包含 * @param {Array<string>} list * @param {string} target * @return {boolean} * @example * fuzzyIncludes([ 'asdadaAAA', 'xczxcBBB' ], 'asdadaAAA') // true 全字匹配 * fuzzyIncludes([ 'asdadaAAA', 'xczxcBBB' ], 'xczxcBBB') // true 全字匹配 * fuzzyIncludes([ 'asdadaAAA', 'xczxcBBB' ], 'AAA') // true 子项匹配 * fuzzyIncludes([ 'asdadaAAA', 'xczxcBBB' ], 'BBB') // true 子项匹配 */ export declare function fuzzyIncludes(list: string[], target: string): boolean; /** * 宽松比较字符串(忽略大小写) * @private * @param {string} str1 * @param {string} str2 * @returns {boolean} * @example * shallowEqual('abc', 'abc') // true * shallowEqual('abc', 'ABC') // true * shallowEqual('abc', 'Bcd') // false */ export declare function shallowEqual(str1: string, str2: string): boolean; /** * target 是否命中 glob 表达式 * @param {string} target * @param {string[]} patterns “glob表达式字符串”,所组成的数组 * @returns {boolean} * @example * const isMatched = isMatchPatterns('a/b/c/d/e', ['a/b/c/d/e', 'a/b/c/d/*', 'a/b/c/*', 'a/b/*', 'a/*', '*']); // true */ export declare function isMatchPatterns(target: string, patterns: string[] | string): boolean; /** * 格式化过滤器数组 * @param {any[]} filters * @returns {string[]} */ export declare function formatPatterns(filters: any[]): string[]; /** * 删除地址的协议头 * @param address * @returns {string} 删除了协议头(https:// 或 http:// 或 file://)的地址 */ export declare function delAddrProtocol(address: string): string;