[Pkg-javascript-commits] [node-expat] 168/371: Parser stream interface: write() & end() emit 'error'

Jonas Smedegaard dr at jones.dk
Sun Feb 28 09:59:58 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 bde1fcb2656661a4ae14164cec833a1771f9a594
Author: Astro <astro at spaceboyz.net>
Date:   Fri Jun 22 03:41:02 2012 +0200

    Parser stream interface: write() & end() emit 'error'
---
 lib/node-expat.js | 25 +++++++++++++++++++++----
 1 file changed, 21 insertions(+), 4 deletions(-)

diff --git a/lib/node-expat.js b/lib/node-expat.js
index b78aaa8..b023693 100644
--- a/lib/node-expat.js
+++ b/lib/node-expat.js
@@ -44,11 +44,28 @@ Parser.prototype.destroySoon = function() {
   this.destroy();
 };
 
-Parser.prototype.write = Parser.prototype.parse;
+Parser.prototype.write = function(data) {
+    try {
+	this.parse(data);
+    } catch (e) {
+	this.emit('error', e);
+	this.emit('close');
+    }
+};
+
+Parser.prototype.end = function(data) {
+    var error;
+    try {
+	this.parse(data || "", true);
+    } catch (e) {
+	error = e;
+    }
 
-Parser.prototype.end = function() {
-  this.emit('end');
-  this.emit('close');
+    if (!error)
+	this.emit('end');
+    else
+	this.emit('error', error);
+    this.emit('close');
 };
 
 Parser.prototype.reset = function() {

-- 
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