Skip to content

Commit

Permalink
Use functions instead of a separate module wrapper class
Browse files Browse the repository at this point in the history
  • Loading branch information
mdaines committed Sep 27, 2024
1 parent 7d96109 commit 5745c60
Show file tree
Hide file tree
Showing 2 changed files with 205 additions and 213 deletions.
14 changes: 7 additions & 7 deletions packages/viz/src/viz.mjs
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
import Wrapper from "./wrapper.mjs";
import { getGraphvizVersion, getPluginList, renderInput } from "./wrapper.mjs";

class Viz {
constructor(module) {
this.wrapper = new Wrapper(module);
this.module = module;
}

get graphvizVersion() {
return this.wrapper.getGraphvizVersion();
return getGraphvizVersion(this.module);
}

get formats() {
return this.wrapper.getPluginList("device");
return getPluginList(this.module, "device");
}

get engines() {
return this.wrapper.getPluginList("layout");
return getPluginList(this.module, "layout");
}

renderFormats(input, formats, options = {}) {
return this.wrapper.renderInput(input, formats, { engine: "dot", ...options });
return renderInput(this.module, input, formats, { engine: "dot", ...options });
}

render(input, options = {}) {
Expand All @@ -30,7 +30,7 @@ class Viz {
format = options.format;
}

let result = this.wrapper.renderInput(input, [format], { engine: "dot", ...options });
let result = renderInput(this.module, input, [format], { engine: "dot", ...options });

if (result.status === "success") {
result.output = result.output[format];
Expand Down
Loading

0 comments on commit 5745c60

Please sign in to comment.