fix
This commit is contained in:
parent
ac3c66bc1c
commit
ebd8936dae
@ -3,6 +3,7 @@
|
||||
import { Transform } from 'stream';
|
||||
import { GraphStreamJSON } from '../interfaces/GraphStreamJSON';
|
||||
import { GraphStreamCommand } from '../enums/GraphStreamCommand';
|
||||
import { validate_name } from '../Helper';
|
||||
|
||||
interface Stringable {
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
@ -119,24 +120,26 @@ export class GraphStream extends Transform {
|
||||
return super.write (JSON.stringify (instr), 'utf-8');
|
||||
}
|
||||
|
||||
public create_node (name: string): boolean {
|
||||
return this.write ({ type: 'cn', args: [ name ] });
|
||||
public create_node (name: string): string {
|
||||
const node_name = validate_name (name);
|
||||
this.write ({ type: 'cn', args: [ node_name ] });
|
||||
return `${this.path}_${node_name}`;
|
||||
}
|
||||
|
||||
public end_node (): boolean {
|
||||
return this.write ({ type: 'en', args: [] });
|
||||
public end_node (): void {
|
||||
this.write ({ type: 'en', args: [] });
|
||||
}
|
||||
|
||||
public create_graph (name: string, type: 'u'|'d'|'s' = 's'): boolean {
|
||||
public create_graph (name: string, type: 'u'|'d'|'s' = 's'): void {
|
||||
const instr_type = `c${type}g` as GraphStreamCommand;
|
||||
return this.write ({ type: instr_type, args: [ name ] });
|
||||
this.write ({ type: instr_type, args: [ validate_name (name) ] });
|
||||
}
|
||||
|
||||
public end_graph (): boolean {
|
||||
return this.write ({ type: 'eg', args: [] });
|
||||
public end_graph (): void {
|
||||
this.write ({ type: 'eg', args: [] });
|
||||
}
|
||||
|
||||
public attributes (attrs: Record<string, Stringable>): boolean {
|
||||
public attributes (attrs: Record<string, Stringable>): void {
|
||||
const solved = [];
|
||||
for (const attr of Object.keys (attrs)) {
|
||||
const val = attrs[attr].toString ();
|
||||
@ -145,11 +148,11 @@ export class GraphStream extends Transform {
|
||||
else
|
||||
solved.push (`${attr} = "${val}"`);
|
||||
}
|
||||
return this.write ({ type: 'at', args: solved });
|
||||
this.write ({ type: 'at', args: solved });
|
||||
}
|
||||
|
||||
public create_edge (origin: string, target: string): boolean {
|
||||
return this.write ({
|
||||
public create_edge (origin: string, target: string): void {
|
||||
this.write ({
|
||||
type: 'ce',
|
||||
args: [
|
||||
origin,
|
||||
|
Loading…
x
Reference in New Issue
Block a user