( formatId: string, options: ParseOptions )
| 142 | * @yields 解析事件流 |
| 143 | */ |
| 144 | export async function* parseFileWithFormat( |
| 145 | formatId: string, |
| 146 | options: ParseOptions |
| 147 | ): AsyncGenerator<ParseEvent, void, unknown> { |
| 148 | const parser = sniffer.getParserById(formatId) |
| 149 | if (!parser) { |
| 150 | yield { type: 'error', data: new Error(`未知的格式 ID: ${formatId}`) } |
| 151 | return |
| 152 | } |
| 153 | |
| 154 | console.log(`[Parser V2] Using parser (explicit): ${parser.feature.name}`) |
| 155 | yield* parser.parse(options) |
| 156 | } |
| 157 | |
| 158 | /** |
| 159 | * 同步解析文件(收集所有事件为完整结果) |
no test coverage detected