Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
rehydrate(value: any): any {
if (Array.isArray(value)) {
// noinspection JSUnresolvedFunction
return value.map(entry => this.rehydrate(entry))
}
if (value instanceof neo4j.types.Node) {
return this.rehydrateNode(value)
}
if (value instanceof neo4j.types.Relationship) {
return this.rehydrateRelation(value)
}
if (neo4j.isInt(value)) {
// noinspection JSUnresolvedFunction
return value.toNumber()
}
return value
}
return new Promise((resolve, reject) => {
if (neo4j.isInt(obj)) return resolve(obj);
var id;
if (requireData) {
id = typeof obj == 'object' ? obj[this.options.id] : undefined;
} else {
id = typeof obj == 'object' ? obj[this.options.id] : obj;
}
if (id != null) id = parseInt(id, 10);
if (isNaN(id) || id == null) return reject(new Error("Invalid ID"));
resolve(neo4j.int(id));
});
}
private transformValue(value: any): any {
if (this.isPlainValue(value)) {
return value;
}
if (isArray(value)) {
return map(value, v => this.transformValue(v));
}
if (neo4j.isInt(value)) {
return this.convertInteger(value);
}
if (this.isNode(value)) {
return this.transformNode(value);
}
if (this.isRelation(value)) {
return this.transformRelation(value);
}
if (typeof value === 'object') {
return mapValues(value, v => this.transformValue(v));
}
return null;
}
return Object.keys(properties).reduce((props, propKey) => {
let value = properties[propKey]
if (neo.isInt(value)) {
props[propKey] = value.toNumber()
} else if (Array.isArray(value)) {
props[propKey] = value.map(item => item.toString()).join(', ')
} else if(neo.isDate(value) || neo.isDateTime(value) || neo.isDuration(value) || neo.isLocalDateTime(value) || neo.isLocalTime(value)) {
props[propKey] = value.toString()
} else {
props[propKey] = value
}
return props
}, {})
}
var treatObj = obj => {
if (typeof obj == 'number') return pr(obj % 1 === 0 ? neo4j.int(obj) : obj);
else if (obj instanceof Promise) return obj.then(val => treatObj(val));
else if (neo4j.isInt(obj)) return pr(obj);
else if (Array.isArray(obj)) return Promise.all(obj.map(treatObj));
else if (typeof obj == 'object' && obj !== null)
return Promise.all(_.map(obj, (v,k) => { return treatObj(v).then(v => [k,v]) }))
.then(tuples => _.object(tuples))
else return pr(obj);
}
return params ? treatObj(params) : pr(params);
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);
}
}
}
}
var assemble = (field) => {
if (Array.isArray(field)) return field.map(assemble);
else if (typeof field != 'object' || !field) return field;
else if (neo4j.isInt(field)) return this._unboxInt(field);
else if (field instanceof neo4j.types.Node) {
var obj = field.properties;
if (this.options.label) obj.labels = field.labels;
obj[this.options.id] = this._unboxInt(field.identity);
return this._unboxAll(obj);
}
else if (field instanceof neo4j.types.Relationship) {
field.start = this._unboxInt(field.start);
field.end = this._unboxInt(field.end);
field[this.options.id] = this._unboxInt(field.identity);
if (this.options.id != 'identity') delete field.identity;
field.properties = this._unboxAll(field.properties);
return field;
}
else if (field instanceof neo4j.types.UnboundRelationship ||
field instanceof neo4j.types.PathSegment ||