Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
rd.on('line', (line) => {
let element: Edge | Vertex = JSON.parse(line);
if (element.type === ElementTypes.vertex) {
switch(element.label) {
case VertexLabels.moniker:
if (element.kind === MonikerKind.local) {
emit(line);
} else {
if (exportLinker !== undefined) {
exportLinker.handleMoniker(element);
}
importLinker.handleMoniker(element);
}
break;
default:
emit(line);
}
} else {
emit(line);
protected createPackageInformation(packageJson: PackageJson): PackageInformation {
let result: PackageInformation = {
id: this.idGenerator(),
type: ElementTypes.vertex,
label: VertexLabels.packageInformation,
name: packageJson.name,
manager: 'npm',
version: packageJson.version
};
if (packageJson.hasRepository()) {
result.repository = packageJson.repository;
}
return result;
}
emit: (element: Vertex | Edge) => {
if (element.type === ElementTypes.vertex) {
let gs: GraphSonVertex;
let values: GraphSonProperty[];
switch (element.label) {
case 'project':
gs = {
id: element.id,
label: element.label
};
vertices.set(gs.id, gs);
break;
case 'document':
gs = {
id: element.id,
label: element.label,
properties: {
uri: [ { id: idGenerator(), value: element.uri } ]
function shortForm(element: Vertex | Edge): number {
let result: number | undefined;
if (element.type === ElementTypes.vertex) {
result = vertexShortForms.get(element.label);
} else {
result = edgeShortForms.get(element.label);
}
if (result === undefined) {
throw new Error(`Can't compute short form for ${element.label}`);
}
return result;
}
public insert(element: Edge | Vertex): void {
if (element.type === ElementTypes.vertex) {
switch (element.label) {
case VertexLabels.metaData:
this.insertMetaData(element);
break;
case VertexLabels.project:
this.insertProject(element);
break;
case VertexLabels.document:
this.insertDocument(element);
break;
case VertexLabels.packageInformation:
this.insertPackageInformation(element);
break;
case VertexLabels.range:
this.insertRange(element);
break;
emit: (element: Vertex | Edge) => {
if (element.type === ElementTypes.vertex) {
let gs: GraphSonVertex;
let values: GraphSonProperty[];
switch (element.label) {
case 'project':
gs = {
id: element.id,
label: element.label
};
vertices.set(gs.id, gs);
break;
case 'document':
gs = {
id: element.id,
label: element.label,
properties: {
uri: [ { id: idGenerator(), value: element.uri } ]
public insert(element: Edge | Vertex): void {
if (element.type === ElementTypes.vertex) {
switch(element.label) {
case VertexLabels.metaData:
this.handleMetaData(element);
break;
case VertexLabels.document:
this.documents.set(element.id, element);
break;
case VertexLabels.range:
this.handleRange(element);
break;
case VertexLabels.resultSet:
this.handleResultSet(element);
break;
case VertexLabels.moniker:
this.handleMoniker(element);
break;
rd.on('line', (line: string) => {
if (!line || line.length === 0) {
return;
}
let element: Edge | Vertex = JSON.parse(line);
switch (element.type) {
case ElementTypes.vertex:
this.processVertex(element);
break;
case ElementTypes.edge:
this.processEdge(element);
break;
}
});
rd.on('close', () => {