This commit is contained in:
parent
040e421d9b
commit
de5810d368
@ -1,5 +1,11 @@
|
||||
# Changelog
|
||||
|
||||
## 1.3.0
|
||||
|
||||
Stream:
|
||||
|
||||
- property to read current node count
|
||||
|
||||
## 1.2.0
|
||||
|
||||
Stream:
|
||||
|
@ -1,6 +1,6 @@
|
||||
# @sapphirecode/graphviz-builder
|
||||
|
||||
version: 1.2.x
|
||||
version: 1.3.x
|
||||
|
||||
constructing graphviz files using an easy typescript interface
|
||||
|
||||
@ -44,6 +44,10 @@ g.add_graph(sg=>{
|
||||
|
||||
sg.add_node('foo');
|
||||
})
|
||||
|
||||
// get info about current stream state
|
||||
g.node_count // count of nodes written
|
||||
g.path // get current path (parent graph names separated by underscores)
|
||||
```
|
||||
|
||||
## License
|
||||
|
@ -21,6 +21,7 @@ interface Stringable {
|
||||
}
|
||||
|
||||
export class GraphStream extends Transform {
|
||||
private _node_count = 0;
|
||||
private _path: string[] = [];
|
||||
private _state: (GraphStreamCommand | '')[] = [
|
||||
'',
|
||||
@ -33,6 +34,10 @@ export class GraphStream extends Transform {
|
||||
return this._path.join ('_');
|
||||
}
|
||||
|
||||
public get node_count (): number {
|
||||
return this._node_count;
|
||||
}
|
||||
|
||||
private get level (): string {
|
||||
return ' '.repeat (this._path.length);
|
||||
}
|
||||
@ -114,6 +119,7 @@ export class GraphStream extends Transform {
|
||||
case 'cn': // create node
|
||||
this.finish_node ();
|
||||
this.push (`${this.level}${this.path}_${instr.args[0]}`);
|
||||
this._node_count++;
|
||||
break;
|
||||
case 'at': // add attributes
|
||||
if ([
|
||||
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@sapphirecode/graphviz-builder",
|
||||
"main": "dist/lib/index.js",
|
||||
"version": "1.2.9",
|
||||
"version": "1.3.0",
|
||||
"author": "Timo Hocker <timo@scode.ovh>",
|
||||
"description": "constructing graphviz files using an easy typescript interface",
|
||||
"repository": {
|
||||
|
Loading…
x
Reference in New Issue
Block a user