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

Method sniff

packages/parser/src/sniffer.ts:88–99  ·  view source on GitHub ↗

* 嗅探文件格式 * @param filePath 文件路径 * @returns 匹配的格式特征,如果无法识别则返回 null

(filePath: string)

Source from the content-addressed store, hash-verified

86 * @returns 匹配的格式特征,如果无法识别则返回 null
87 */
88 sniff(filePath: string): FormatFeature | null {
89 const ext = getExtension(filePath)
90 const headContent = readFileHead(filePath)
91
92 for (const { feature } of this.formats) {
93 if (this.matchFeature(feature, ext, headContent, filePath)) {
94 return feature
95 }
96 }
97
98 return null
99 }
100
101 /**
102 * 获取文件对应的解析器

Callers 4

detectFormatFunction · 0.80
getPreprocessorFunction · 0.80
scanMultiChatFileFunction · 0.80
parseFileInfoFunction · 0.80

Calls 3

matchFeatureMethod · 0.95
getExtensionFunction · 0.85
readFileHeadFunction · 0.85

Tested by

no test coverage detected