node-expat
Advanced tools
Comparing version 2.3.2 to 2.3.3
@@ -1,105 +0,112 @@ | ||
var EventEmitter = require('events').EventEmitter; | ||
var util = require('util'); | ||
var EventEmitter = require('events').EventEmitter | ||
var util = require('util') | ||
// Only support nodejs v0.6 and on so no need to look for older module location | ||
var expat = require('bindings')('node_expat'); | ||
var Stream = require('stream').Stream; | ||
var expat = require('bindings')('node_expat') | ||
var Stream = require('stream').Stream | ||
var Parser = function(encoding) { | ||
this.parser = new expat.Parser(encoding); | ||
this.parser.emit = this.emit.bind(this); | ||
this.encoding = encoding | ||
this._getNewParser() | ||
this.parser.emit = this.emit.bind(this) | ||
//stream API | ||
this.writable = true; | ||
this.readable = true; | ||
}; | ||
util.inherits(Parser, Stream); | ||
// Stream API | ||
this.writable = true | ||
this.readable = true | ||
} | ||
util.inherits(Parser, Stream) | ||
Parser.prototype._getNewParser = function() { | ||
this.parser = new expat.Parser(this.encoding) | ||
} | ||
Parser.prototype.parse = function(buf, isFinal) { | ||
return this.parser.parse(buf, isFinal); | ||
}; | ||
return this.parser.parse(buf, isFinal) | ||
} | ||
Parser.prototype.setEncoding = function(encoding) { | ||
return this.parser.setEncoding(encoding); | ||
}; | ||
this.encoding = encoding | ||
return this.parser.setEncoding(this.encoding) | ||
} | ||
Parser.prototype.setUnknownEncoding = function(map, convert) { | ||
return this.parser.setUnknownEncoding(map, convert); | ||
}; | ||
return this.parser.setUnknownEncoding(map, convert) | ||
} | ||
Parser.prototype.getError = function() { | ||
return this.parser.getError(); | ||
}; | ||
return this.parser.getError() | ||
} | ||
Parser.prototype.stop = function() { | ||
return this.parser.stop(); | ||
}; | ||
return this.parser.stop() | ||
} | ||
Parser.prototype.pause = function() { | ||
return this.stop(); | ||
}; | ||
return this.stop() | ||
} | ||
Parser.prototype.resume = function() { | ||
return this.parser.resume(); | ||
}; | ||
return this.parser.resume() | ||
} | ||
Parser.prototype.destroy = function() { | ||
this.parser.stop(); | ||
this.end(); | ||
}; | ||
this.parser.stop() | ||
this.end() | ||
} | ||
Parser.prototype.destroySoon = function() { | ||
this.destroy(); | ||
}; | ||
this.destroy() | ||
} | ||
Parser.prototype.write = function(data) { | ||
var error, result; | ||
var error, result | ||
try { | ||
result = this.parse(data); | ||
result = this.parse(data) | ||
if (!result) | ||
error = this.getError(); | ||
error = this.getError() | ||
} catch (e) { | ||
error = e; | ||
error = e | ||
} | ||
if (error) { | ||
this.emit('error', error); | ||
this.emit('close'); | ||
this.emit('error', error) | ||
this.emit('close') | ||
} | ||
return result; | ||
}; | ||
return result | ||
} | ||
Parser.prototype.end = function(data) { | ||
var error, result; | ||
var error, result | ||
try { | ||
result = this.parse(data || "", true); | ||
result = this.parse(data || '', true) | ||
if (!result) | ||
error = this.getError(); | ||
error = this.getError() | ||
} catch (e) { | ||
error = e; | ||
error = e | ||
} | ||
if (!error) | ||
this.emit('end'); | ||
else | ||
this.emit('error', error); | ||
this.emit('close'); | ||
}; | ||
if (!error) { | ||
this.emit('end') | ||
} else { | ||
this.emit('error', error) | ||
} | ||
this.emit('close') | ||
} | ||
Parser.prototype.reset = function() { | ||
return this.parser.reset(); | ||
}; | ||
return this.parser.reset() | ||
} | ||
Parser.prototype.getCurrentLineNumber = function() { | ||
return this.parser.getCurrentLineNumber(); | ||
}; | ||
return this.parser.getCurrentLineNumber() | ||
} | ||
Parser.prototype.getCurrentColumnNumber = function() { | ||
return this.parser.getCurrentColumnNumber(); | ||
}; | ||
return this.parser.getCurrentColumnNumber() | ||
} | ||
Parser.prototype.getCurrentByteIndex = function() { | ||
return this.parser.getCurrentByteIndex(); | ||
}; | ||
return this.parser.getCurrentByteIndex() | ||
} | ||
//Exports | ||
exports.Parser = Parser | ||
exports.Parser = Parser; | ||
exports.createParser = function(cb) { | ||
var parser = new Parser(); | ||
if(cb) { parser.on('startElement', cb); } | ||
return parser; | ||
}; | ||
var parser = new Parser() | ||
if (cb) { | ||
parser.on('startElement', cb) | ||
} | ||
return parser | ||
} |
{ | ||
"name": "node-expat", | ||
"version": "2.3.2", | ||
"version": "2.3.3", | ||
"main": "./lib/node-expat", | ||
@@ -15,7 +15,8 @@ "description": "NodeJS binding for fast XML parsing.", | ||
"scripts": { | ||
"test": "vows --spec ./test.js" | ||
"test": "vows --spec ./test/**/*.js" | ||
}, | ||
"dependencies": { | ||
"bindings": "~1.2.1", | ||
"nan": "~1.3.0" | ||
"debug": "~2.1.0", | ||
"nan": "~1.4.1" | ||
}, | ||
@@ -22,0 +23,0 @@ "devDependencies": { |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
3963032
637
3
2
+ Addeddebug@~2.1.0
+ Addeddebug@2.1.3(transitive)
+ Addedms@0.7.0(transitive)
+ Addednan@1.4.3(transitive)
- Removednan@1.3.0(transitive)
Updatednan@~1.4.1