Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function isNeo4jValue (value) {
switch (get(value, 'constructor')) {
case neo4j.types.Date:
case neo4j.types.DateTime:
case neo4j.types.Duration:
case neo4j.types.LocalDateTime:
case neo4j.types.LocalTime:
case neo4j.types.Time:
case neo4j.types.Integer: // not exposed in typings but still there
return true
default:
return false
}
}
function isNeo4jValue (value) {
switch (get(value, 'constructor')) {
case neo4j.types.Date:
case neo4j.types.DateTime:
case neo4j.types.Duration:
case neo4j.types.LocalDateTime:
case neo4j.types.LocalTime:
case neo4j.types.Time:
case neo4j.types.Integer: // not exposed in typings but still there
return true
default:
return false
}
}
export const isGraphItem = (types = neo4j.types, item) => {
return (
item instanceof types.Node ||
item instanceof types.Relationship ||
item instanceof types.Path ||
item instanceof types.PathSegment ||
item instanceof neo4j.types.Date ||
item instanceof neo4j.types.DateTime ||
item instanceof neo4j.types.Duration ||
item instanceof neo4j.types.LocalDateTime ||
item instanceof neo4j.types.LocalTime ||
item instanceof neo4j.types.Time ||
item instanceof neo4j.types.Point
)
}
for (let obj of v.segments) {
this._addNode(await this.buildNodeVisObject(obj.start));
this._addNode(await this.buildNodeVisObject(obj.end));
this._addEdge(this.buildEdgeVisObject(obj.relationship));
}
} else if (v instanceof Array) {
for (let obj of v) {
this._consoleLog('Array element constructor:');
this._consoleLog(obj && obj.constructor.name);
if (obj instanceof Neo4j.types.Node) {
let node = await this.buildNodeVisObject(obj);
this._addNode(node);
} else if (obj instanceof Neo4j.types.Relationship) {
let edge = this.buildEdgeVisObject(obj);
this._addEdge(edge);
}
}
}
});
dataBuildPromises.push(Promise.all(dataPromises));
export const recursivelyTypeGraphItems = (item, types = neo4j.types) => {
if (item === null || item === undefined) {
return item
}
if (['number', 'string', 'boolean'].indexOf(typeof item) !== -1) {
return item
}
if (Array.isArray(item)) {
return item.map(i => recursivelyTypeGraphItems(i, types))
}
if (item instanceof types.Node) {
const tmp = copyAndType(item, types)
safetlyAddObjectProp(tmp, reservedTypePropertyName, 'Node')
return tmp
}
if (item instanceof types.PathSegment) {
const tmp = copyAndType(item, types)
export const isGraphItem = (types = neo4j.types, item) => {
return (
item instanceof types.Node ||
item instanceof types.Relationship ||
item instanceof types.Path ||
item instanceof types.PathSegment ||
item instanceof neo4j.types.Date ||
item instanceof neo4j.types.DateTime ||
item instanceof neo4j.types.Duration ||
item instanceof neo4j.types.LocalDateTime ||
item instanceof neo4j.types.LocalTime ||
item instanceof neo4j.types.Time ||
item instanceof neo4j.types.Point
)
}
const records = result.records.map(record => {
const typedRecord = new neo4j.types.Record(
record.keys,
record._fields,
record._fieldLookup
)
if (typedRecord._fields) {
typedRecord._fields = mappings.applyGraphTypes(typedRecord._fields)
}
return typedRecord
})
const summary = mappings.applyGraphTypes(result.summary)
export function extractFromNeoObjects(obj, converters) {
if (
obj instanceof neo4j.types.Node ||
obj instanceof neo4j.types.Relationship
) {
return obj.properties
} else if (obj instanceof neo4j.types.Path) {
return [].concat.apply([], extractPathForRows(obj, converters))
}
return obj
}