MCPcopy Create free account
hub / github.com/LeetCode-OpenSource/vscode-leetcode / getNodeIdFromFile

Function getNodeIdFromFile

src/utils/problemUtils.ts:23–36  ·  view source on GitHub ↗
(fsPath: string)

Source from the content-addressed store, hash-verified

21}
22
23export async function getNodeIdFromFile(fsPath: string): Promise<string> {
24 const fileContent: string = await fse.readFile(fsPath, "utf8");
25 let id: string = "";
26 const matchResults: RegExpMatchArray | null = fileContent.match(/@lc.+id=(.+?) /);
27 if (matchResults && matchResults.length === 2) {
28 id = matchResults[1];
29 }
30 // Try to get id from file name if getting from comments failed
31 if (!id) {
32 id = path.basename(fsPath).split(".")[0];
33 }
34
35 return id;
36}

Callers 1

previewProblemFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected