[Pkg-javascript-commits] [node-jsonstream] 162/214: Fix stream error

Bastien Roucariès rouca at moszumanska.debian.org
Fri Dec 1 12:58:54 UTC 2017


This is an automated email from the git hooks/post-receive script.

rouca pushed a commit to branch master
in repository node-jsonstream.

commit a1a06533c6d14e967c05f257d451d7d8bddadbfe
Author: Guillaume Chauvet <gchauvet at zatarox.com>
Date:   Sun Aug 23 08:11:57 2015 +0200

    Fix stream error
---
 index.js       |  9 +++------
 test/issues.js | 10 ++++++----
 2 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/index.js b/index.js
index 1c55492..97e5144 100755
--- a/index.js
+++ b/index.js
@@ -20,7 +20,9 @@ exports.parse = function (path, map) {
       chunk = new Buffer(chunk)
     try {
       parser.write(chunk);
-    } catch(e)  {
+    } catch(e) {
+      stream.emit('error', e);
+      stream.destroy();
     }
   },
   function (data) {
@@ -111,11 +113,6 @@ exports.parse = function (path, map) {
     stream.emit('error', err)
   }
   
-  parser.parseError = function(token, value) {
-      this.onError(new Error("Unexpected value " (value ? ("(" + JSON.stringify(value) + ")") : "")));
-  }
-
-
   return stream
 }
 
diff --git a/test/issues.js b/test/issues.js
index f0bd464..d852216 100644
--- a/test/issues.js
+++ b/test/issues.js
@@ -2,17 +2,19 @@ var JSONStream = require('../');
 var test = require('tape')
 
 test('#66', function (t) {
-
-    var stream = JSONStream
+  var passed = false;
+   var stream = JSONStream
     .parse()
     .on('error', function (err) {
-        t.ifError(err);
+        t.ok(err);
+        passed = true;
     })
     .on('end', function () {
+        t.ok(passed);
         t.end();
     });
 
     stream.write('["foo":bar[');
     stream.end();
 
-});
\ No newline at end of file
+});

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-jsonstream.git



More information about the Pkg-javascript-commits mailing list