-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dadc151
commit d168752
Showing
3 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
|
||
const graphviz = {}; | ||
|
||
graphviz.ModelFactory = class { | ||
|
||
match(context) { | ||
const reader = context.read('text', 0x10000); | ||
if (reader) { | ||
try { | ||
const line = reader.read('\n'); | ||
if (line === undefined) { | ||
return; | ||
} | ||
if (line.indexOf('digraph') !== -1) { | ||
context.type = 'graphviz.dot'; | ||
} | ||
} catch { | ||
// continue regardless of error | ||
} | ||
} | ||
} | ||
|
||
async open(/* context */) { | ||
throw new graphviz.Error('Invalid file content. File contains Graphviz data.'); | ||
} | ||
}; | ||
|
||
graphviz.Error = class extends Error { | ||
|
||
constructor(message) { | ||
super(message); | ||
this.name = 'Error loading Graphviz model.'; | ||
} | ||
}; | ||
|
||
export const ModelFactory = graphviz.ModelFactory; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters