MCPcopy
hub / github.com/compiler-explorer/compiler-explorer / extractEditorSources

Function extractEditorSources

static/history.ts:35–51  ·  view source on GitHub ↗
(content: any[])

Source from the content-addressed store, hash-verified

33export type EditorSource = {lang: string; source: string};
34
35function extractEditorSources(content: any[]): EditorSource[] {
36 const sources: EditorSource[] = [];
37 for (const component of content) {
38 if (component.content) {
39 const subsources = extractEditorSources(component.content);
40 if (subsources.length > 0) {
41 sources.push(...subsources);
42 }
43 } else if (component.componentName === 'codeEditor') {
44 sources.push({
45 lang: component.componentState.lang,
46 source: component.componentState.source,
47 });
48 }
49 }
50 return sources;
51}
52
53function list(): HistoryEntry[] {
54 return JSON.parse(localStorage.get('history', '[]'));

Callers 1

pushFunction · 0.85

Calls 1

pushMethod · 0.80

Tested by

no test coverage detected