Comparing version 0.0.6 to 0.1.0
@@ -7,2 +7,3 @@ var util = require('util'); | ||
var debug = require('debug')('jipe.inquiry'); | ||
var pp = require('./pp'); | ||
@@ -24,3 +25,6 @@ function InquiryStream(options) { | ||
var output = this._query(input); | ||
if (output.length == 1) { | ||
if (output.length === 1 && output[0] === null) { | ||
debug('output: null'); | ||
this.push(pp.NULL); | ||
} else if (output.length === 1) { | ||
debug('output: %j', output[0]); | ||
@@ -27,0 +31,0 @@ this.push(output[0]); |
@@ -5,2 +5,3 @@ var util = require('util'); | ||
var pp = require('./pp'); | ||
var jevel = require('JSONPath').eval; | ||
@@ -28,7 +29,11 @@ var debug = require('debug')('jipe.jsonpath'); | ||
var output = this._query(input); | ||
if (output.length == 1) { | ||
debug('output: %j', output[0]); | ||
debug('output: %j', output); | ||
if (output.length === 1 && output[0] === null ) { | ||
debug('writing: null'); | ||
this.push(pp.NULL); | ||
} else if (output.length === 1) { | ||
debug('writing: %j', output[0]); | ||
this.push(output[0]); | ||
} else if (output.length > 1) { | ||
debug('output: %j', output); | ||
debug('writing: %j', output); | ||
this.push(output); | ||
@@ -35,0 +40,0 @@ } |
{ | ||
"name": "jipe", | ||
"version": "0.0.6", | ||
"version": "0.1.0", | ||
"description": "Filter, extract from and pretty print a stream of JSON objects.", | ||
@@ -33,7 +33,7 @@ "main": "index.js", | ||
"dependencies": { | ||
"JSONPath": "^0.10.0", | ||
"debug": "~0.7.4", | ||
"inquiry": "0.0.2", | ||
"optimist": "~0.6.0", | ||
"inquiry": "0.0.2", | ||
"underscore": "~1.5.2", | ||
"JSONPath": "~0.9.1" | ||
"underscore": "~1.5.2" | ||
}, | ||
@@ -40,0 +40,0 @@ "devDependencies": { |
12
pp.js
@@ -24,7 +24,15 @@ var util = require('util'); | ||
JSONPrintStream.prototype._transform = function(obj, _, done) { | ||
debug('printing %j', obj); | ||
this.push(JSON.stringify(obj, null, this._indent) + '\n'); | ||
if (obj !== JSONPrintStream.NULL) { | ||
debug('printing %j', obj); | ||
this.push(JSON.stringify(obj, null, this._indent) + '\n'); | ||
} else { | ||
debug('printing null'); | ||
this.push('null\n'); | ||
} | ||
done(); | ||
}; | ||
/* null placeholder since passing in null ends the stream */ | ||
JSONPrintStream.NULL = new Object(); | ||
module.exports = JSONPrintStream; |
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
17062
403
+ AddedJSONPath@0.10.0(transitive)
- RemovedJSONPath@0.9.1(transitive)
- Removedunderscore@1.3.3(transitive)
UpdatedJSONPath@^0.10.0