Skip to content

Commit

Permalink
Remove unnecessary extractData method (which also causes a bug when r…
Browse files Browse the repository at this point in the history
…esults named 'data' are involved.
  • Loading branch information
brian-gates committed Nov 22, 2014
1 parent 4e121f0 commit 1c00cf3
Showing 1 changed file with 1 addition and 21 deletions.
22 changes: 1 addition & 21 deletions CypherStream.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,6 @@ var normalize = require('./normalize-query-statement');

util.inherits(CypherStream, Readable);

// recursively replace each node with its data property if available
function extractData(item) {
if (!item) {
return item;
}
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;
}

function CypherStream(databaseUrl, statements, options) {
Readable.call(this, { objectMode: true });
statements = normalize(statements).filter(function (statement) {
Expand Down Expand Up @@ -124,7 +104,7 @@ function CypherStream(databaseUrl, statements, options) {
stream.node('!results[*].data[*].row', function CypherStreamNodeData(result, path, ancestors) {
var data = {};
columns.forEach(function (column, i) {
data[column] = extractData(result[i]);
data[column] = result[i];
});
if (callbackStream) {
callbackStream.write(data);
Expand Down

0 comments on commit 1c00cf3

Please sign in to comment.