MCPcopy Index your code
hub / github.com/ChatLab/ChatLab / streamParseFile

Function streamParseFile

packages/parser/src/index.ts:340–370  ·  view source on GitHub ↗
(
  filePath: string,
  callbacks: Omit<StreamParseOptions, 'filePath'>,
  formatId?: string
)

Source from the content-addressed store, hash-verified

338 * @param formatId 可选,指定格式 ID(用于 fallback 机制,跳过自动检测)
339 */
340export async function streamParseFile(
341 filePath: string,
342 callbacks: Omit<StreamParseOptions, 'filePath'>,
343 formatId?: string
344): Promise<void> {
345 const { onProgress, onMeta, onMembers, onMessageBatch, onLog, batchSize = 5000, formatOptions } = callbacks
346
347 // 根据是否指定 formatId 选择解析方式
348 const generator = formatId
349 ? parseFileWithFormat(formatId, { filePath, batchSize, formatOptions, onProgress, onLog })
350 : parseFile({ filePath, batchSize, formatOptions, onProgress, onLog })
351
352 for await (const event of generator) {
353 switch (event.type) {
354 case 'meta':
355 onMeta(event.data)
356 break
357 case 'members':
358 onMembers(event.data)
359 break
360 case 'messages':
361 onMessageBatch(event.data)
362 break
363 case 'progress':
364 onProgress(event.data)
365 break
366 case 'error':
367 throw event.data
368 }
369 }
370}

Callers 5

streamImportSingleFunction · 0.90
analyzeNewImportFunction · 0.90
streamParseFileInfoFunction · 0.90
analyzeIncrementalImportFunction · 0.90
incrementalImportFunction · 0.90

Calls 3

parseFileWithFormatFunction · 0.85
parseFileFunction · 0.85
onProgressFunction · 0.50

Tested by

no test coverage detected