Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
static _transformProperty(property) {
if (neo4j.isInt(property)) {
if (neo4j.integer.inSafeRange(property)) {
return property.toNumber();
}
return property.toString();
}
if (Array.isArray(property)) {
const newArray = [];
for (const item of property) {
newArray.push(Neo4jDB._transformProperty(item));
}
return newArray;
}
return property;
}
private transformRelation(rel: NeoRelation): Relation {
return {
identity: neo4j.integer.toString(rel.identity),
start: neo4j.integer.toString(rel.start),
end: neo4j.integer.toString(rel.end),
label: rel.type,
properties: mapValues(rel.properties, this.transformValue.bind(this)),
};
}
private convertInteger(num: Integer) {
if (neo4j.integer.inSafeRange(num)) {
return neo4j.integer.toNumber(num);
}
return neo4j.integer.toString(num);
}
}
transform(object) {
for (let property in object) {
if (object.hasOwnProperty(property)) {
const propertyValue = object[property];
if (db.isInt(propertyValue)) {
if (db.integer.inSafeRange(propertyValue)) {
object[property] = propertyValue.toNumber();
} else {
object[property] = propertyValue.toString();
}
} else if (typeof propertyValue === "object") {
this.transform(propertyValue);
}
}
}
}