MCPcopy Create free account
hub / github.com/compiler-explorer/compiler-explorer / readExamples

Function readExamples

lib/sources/builtin.ts:34–48  ·  view source on GitHub ↗
(examplesPath: string)

Source from the content-addressed store, hash-verified

32const NAME_SUBSTUTION_PATTERN = /_/g;
33
34function readExamples(examplesPath: string): SourceEntry[] {
35 return fs.readdirSync(examplesPath).flatMap(folder => {
36 const folderPath = path.join(examplesPath, folder);
37 return fs.readdirSync(folderPath).map(file => {
38 const filePath = path.join(folderPath, file);
39 const fileName = path.parse(filePath).name;
40 return {
41 lang: folder,
42 name: fileName.replaceAll(NAME_SUBSTUTION_PATTERN, ' '),
43 path: filePath,
44 file: fileName,
45 };
46 });
47 });
48}
49
50export class BuiltinSource implements Source {
51 readonly name = 'Examples';

Callers 1

constructorMethod · 0.85

Calls 2

replaceAllMethod · 0.80
parseMethod · 0.45

Tested by

no test coverage detected