/** * 根据关键词过滤数组元素 * * @template T - 数组元素类型 * @param {T} source - 要搜索的源数组,不会修改原数组 * @param {string} [keyword] - 搜索关键词。如果未提供或为空字符串,则返回原数组的浅拷贝 * @returns {T} 包含匹配元素的新数组,保持原数组顺序。如果没有匹配项,返回空数组 * * @example * // 基本用法 - 字符串数组 * const fruits = ['apple', 'banana', 'grape']; * const result = filterArrayByKeyword(fruits, 'ap'); * // => ['apple', 'grape'] * * @example * // 对象数组 - 搜索所有属性值 * const users = [ * { name: 'John', email: 'john@example.com' }, * { name: 'Jane', email: 'jane@test.com' } * ]; * const filteredUsers = filterArrayByKeyword(users, 'example'); * // => [{ name: 'John', email: 'john@example.com' }] * * @example * // 空关键词情况 * const numbers = [1, 2, 3]; * const unchanged = filterArrayByKeyword(numbers); * // => [1, 2, 3] * * @example * // 无匹配项 * const data = ['cat', 'dog', 'bird']; * const noMatch = filterArrayByKeyword(data, 'fish'); * // => [] * * @remarks * - 搜索区分大小写 * - 对于对象元素,会递归搜索所有可枚举的字符串属性值 * - 返回新数组,原数组保持不变 */ export declare function filterArrayByKeyword>(source: T, keyword?: string): T;