MCPcopy
hub / github.com/algorithm-visualizer/algorithm-visualizer / build

Function build

src/components/Player/index.js:68–95  ·  view source on GitHub ↗
(file)

Source from the content-addressed store, hash-verified

66 }
67
68 build(file) {
69 this.reset();
70 if (!file) return;
71
72 if (this.tracerApiSource) this.tracerApiSource.cancel();
73 this.tracerApiSource = axios.CancelToken.source();
74 this.setState({ building: true });
75
76 const ext = extension(file.name);
77 if (ext in TracerApi) {
78 TracerApi[ext]({ code: file.content }, undefined, this.tracerApiSource.token)
79 .then(commands => {
80 this.tracerApiSource = null;
81 this.setState({ building: false });
82 this.reset(commands);
83 this.next();
84 })
85 .catch(error => {
86 if (axios.isCancel(error)) return;
87 this.tracerApiSource = null;
88 this.setState({ building: false });
89 this.handleError(error);
90 });
91 } else {
92 this.setState({ building: false });
93 this.handleError(new Error('Language Not Supported'));
94 }
95 }
96
97 isValidCursor(cursor) {
98 const { chunks } = this.props.player;

Callers

nothing calls this directly

Calls 3

extensionFunction · 0.90
handleErrorMethod · 0.80
resetMethod · 0.45

Tested by

no test coverage detected