[Pkg-javascript-commits] [node-expat] 295/371: Minor refactor
Jonas Smedegaard
dr at jones.dk
Sun Feb 28 10:00:22 UTC 2016
This is an automated email from the git hooks/post-receive script.
js pushed a commit to branch master
in repository node-expat.
commit a54b79a9abbd63c3a06bdefbee9c8446bc335923
Author: Lloyd Watkin <lloyd.watkin at surevine.com>
Date: Mon Nov 24 13:48:40 2014 +0000
Minor refactor
---
lib/node-expat.js | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/lib/node-expat.js b/lib/node-expat.js
index b24db23..597a047 100644
--- a/lib/node-expat.js
+++ b/lib/node-expat.js
@@ -5,7 +5,8 @@ var expat = require('bindings')('node_expat')
var Stream = require('stream').Stream
var Parser = function(encoding) {
- this.parser = new expat.Parser(encoding)
+ this.encoding = encoding
+ this._getNewParser()
this.parser.emit = this.emit.bind(this)
// Stream API
@@ -14,12 +15,17 @@ var Parser = function(encoding) {
}
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)
}
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) {
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-expat.git
More information about the Pkg-javascript-commits
mailing list