cypher-stream
Advanced tools
Comparing version 0.1.6 to 0.1.7
21
index.js
@@ -7,4 +7,17 @@ var oboe = require('oboe'); | ||
// recursively replace each node with its data property if available | ||
function extractData(item) { | ||
return item.data; | ||
if(item.data) { | ||
return extractData(item.data); | ||
} | ||
var isArrayOrObject = ['array', 'object'].indexOf(typeof item) !== -1; | ||
if(!isArrayOrObject) { | ||
// filter only objects and arrays | ||
return item; | ||
} | ||
// recurse on each property | ||
Object.keys(item).forEach(function(key){ | ||
item[key] = extractData(item[key]); | ||
}); | ||
return item; | ||
} | ||
@@ -30,7 +43,3 @@ | ||
columns.forEach(function (column, i) { | ||
if(result[i].length && result[i][0].data) { | ||
data[column] = result[i].map(extractData); | ||
return; | ||
} | ||
data[column] = result[i].data || result[i]; | ||
data[column] = extractData(result[i]); | ||
}); | ||
@@ -37,0 +46,0 @@ stream.push(data); |
{ | ||
"name": "cypher-stream", | ||
"version": "0.1.6", | ||
"version": "0.1.7", | ||
"description": "Streams cypher query results in a clean format", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -98,2 +98,11 @@ var should = require('should'); | ||
it('recursively returns data values', function (done) { | ||
cypher('match (n:Test) return { child: { grandchild: n }} as parent limit 1') | ||
.on('data', function (result) { | ||
result.should.eql({ parent: { child: { grandchild: { test: true } } } }); | ||
}) | ||
.on('end', done) | ||
; | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
19561
173