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

Method getParser

packages/parser/src/sniffer.ts:106–117  ·  view source on GitHub ↗

* 获取文件对应的解析器 * @param filePath 文件路径 * @returns 匹配的解析器,如果无法识别则返回 null

(filePath: string)

Source from the content-addressed store, hash-verified

104 * @returns 匹配的解析器,如果无法识别则返回 null
105 */
106 getParser(filePath: string): Parser | null {
107 const ext = getExtension(filePath)
108 const headContent = readFileHead(filePath)
109
110 for (const { feature, parser } of this.formats) {
111 if (this.matchFeature(feature, ext, headContent, filePath)) {
112 return parser
113 }
114 }
115
116 return null
117 }
118
119 /**
120 * 嗅探所有匹配的格式(按优先级排序)

Callers 2

getParserFunction · 0.80
parseFileFunction · 0.80

Calls 3

matchFeatureMethod · 0.95
getExtensionFunction · 0.85
readFileHeadFunction · 0.85

Tested by

no test coverage detected