Comparing version 0.1.0 to 0.1.1
@@ -143,3 +143,3 @@ /** | ||
this.saxStream.on("error", function (e) { | ||
this.emit('error', e); | ||
self.emit('error', e); | ||
@@ -160,7 +160,12 @@ // clear the error and resume | ||
xml2object.prototype.start = function() { | ||
// Can only start once and must have a stream | ||
if(this._hasStarted || !this.inputStream) { | ||
// Can only start once | ||
if(this._hasStarted) { | ||
return; | ||
} | ||
// Must have a stream to start | ||
if(!this.inputStream) { | ||
throw new Error('Missing parsing source'); | ||
} | ||
this._hasStarted = true; | ||
@@ -167,0 +172,0 @@ |
@@ -5,3 +5,3 @@ { | ||
"description": "Simple XML to JavaScript Object Converter", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"homepage": "https://github.com/emberfeather/node-xml2object", | ||
@@ -8,0 +8,0 @@ "repository": { |
@@ -27,3 +27,3 @@ # Node.js xml2object | ||
// Bind to the file end event to tell when the file is done being streamed | ||
parser.on('end', function(name, obj) { | ||
parser.on('end', function() { | ||
console.log('Finished parsing xml!'); | ||
@@ -50,3 +50,3 @@ }); | ||
// Bind to the file end event to tell when the file is done being streamed | ||
parser.on('end', function(name, obj) { | ||
parser.on('end', function() { | ||
console.log('Finished parsing xml!'); | ||
@@ -75,3 +75,3 @@ }); | ||
// Bind to the file end event to tell when the file is done being streamed | ||
parser.on('end', function(name, obj) { | ||
parser.on('end', function() { | ||
console.log('Finished parsing xml!'); | ||
@@ -102,2 +102,6 @@ }); | ||
var parser = new xml2object([ 'animal' ]); | ||
parser.source = 'myAnimals.xml'; | ||
### .saxStream | ||
@@ -104,0 +108,0 @@ |
@@ -28,2 +28,15 @@ var fs = require('fs'); | ||
exports.testNoSource = function(test){ | ||
test.expect(1); | ||
var parser = new xml2object(['cat']); | ||
test.throws(function() { | ||
// Starting without any source should throw an error | ||
parser.start(); | ||
}, Error); | ||
test.done(); | ||
}; | ||
exports.testSetter = function(test){ | ||
@@ -30,0 +43,0 @@ test.expect(3); |
Sorry, the diff of this file is not supported yet
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
14145
12
281
137