* 嗅探所有匹配的格式(按优先级排序) * 用于 fallback 机制:当第一个格式解析失败时尝试下一个 * @param filePath 文件路径 * @returns 所有匹配的格式特征列表
(filePath: string)
| 123 | * @returns 所有匹配的格式特征列表 |
| 124 | */ |
| 125 | sniffAll(filePath: string): FormatFeature[] { |
| 126 | const ext = getExtension(filePath) |
| 127 | const headContent = readFileHead(filePath) |
| 128 | const results: FormatFeature[] = [] |
| 129 | |
| 130 | for (const { feature } of this.formats) { |
| 131 | if (this.matchFeature(feature, ext, headContent, filePath)) { |
| 132 | results.push(feature) |
| 133 | } |
| 134 | } |
| 135 | |
| 136 | return results |
| 137 | } |
| 138 | |
| 139 | /** |
| 140 | * 获取所有匹配的解析器(按优先级排序) |
no test coverage detected