Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var is = R.is;
var isArrayLike = R.isArrayLike;
var isNil = R.isNil;
var map = R.map;
var mapObjIndexed = R.mapObjIndexed;
var prop = R.prop;
var zipObj = R.zipObj;
var recordToNative = converge(zipObj, [prop('keys'), prop('_fields')]);
var isRecord = both(has('_fields'), has('keys'));
// Recursively map Neo4j values
// to their native equivalants
var toNative = cond([
[isNil, identity],
[is(neo4j.types.Node), x => compose(toNative, prop('properties'))(x)],
[is(neo4j.types.Relationship), prop('properties')],
[neo4j.isInt, invoker(0, 'toInt')],
[isArrayLike, x => map(toNative, x)],
[isRecord, x => compose(toNative, recordToNative)(x)],
[is(Object), x => mapObjIndexed(toNative, x)],
[R.T, identity],
]);
module.exports = toNative;
var isArrayLike = R.isArrayLike;
var isNil = R.isNil;
var map = R.map;
var mapObjIndexed = R.mapObjIndexed;
var prop = R.prop;
var zipObj = R.zipObj;
var recordToNative = converge(zipObj, [prop('keys'), prop('_fields')]);
var isRecord = both(has('_fields'), has('keys'));
// Recursively map Neo4j values
// to their native equivalants
var toNative = cond([
[isNil, identity],
[is(neo4j.types.Node), x => compose(toNative, prop('properties'))(x)],
[is(neo4j.types.Relationship), prop('properties')],
[neo4j.isInt, invoker(0, 'toInt')],
[isArrayLike, x => map(toNative, x)],
[isRecord, x => compose(toNative, recordToNative)(x)],
[is(Object), x => mapObjIndexed(toNative, x)],
[R.T, identity],
]);
module.exports = toNative;
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 ||
field instanceof neo4j.types.Path) {
// no processing for these types yet.
return field;
}
else {
return _.reduce(field, (obj, val, key) => {
obj[key] = assemble(val);
return obj;
}, {});
}
}
var processed = records.map((record) => {
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
}
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
}
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 ||
field instanceof neo4j.types.Path) {