[Pkg-javascript-commits] [node-jsonstream] 49/214: Add missing Stream destroy method

Bastien Roucariès rouca at moszumanska.debian.org
Fri Dec 1 12:58:38 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 00396f37b710380f90209abcf27a9fa45d20f84e
Author: Santiago Gimeno <santiago.gimeno at quantion.es>
Date:   Fri Sep 7 13:16:01 2012 +0200

    Add missing Stream destroy method
    
    - Added also a test-case.
---
 index.js                |  5 +++++
 test/destroy_missing.js | 22 ++++++++++++++++++++++
 2 files changed, 27 insertions(+)

diff --git a/index.js b/index.js
index 1bd26a7..66e9d0c 100644
--- a/index.js
+++ b/index.js
@@ -74,6 +74,11 @@ exports.parse = function (path) {
     stream.emit('root', stream.root, count)
     stream.emit('end')
   }
+
+  stream.destroy = function () {
+    stream.emit('close');
+  }
+
   return stream
 }
 
diff --git a/test/destroy_missing.js b/test/destroy_missing.js
new file mode 100644
index 0000000..75fb8a8
--- /dev/null
+++ b/test/destroy_missing.js
@@ -0,0 +1,22 @@
+var fs = require ('fs');
+var net = require('net');
+var join = require('path').join;
+var file = join(__dirname, 'fixtures','all_npm.json');
+var JSONStream = require('../');
+
+
+var server = net.createServer(function(client) {
+    var parser = JSONStream.parse([]);
+    parser.on('close', function() {
+        console.error('PASSED');
+        server.close();
+    });
+    client.pipe(parser);
+    client.destroy();
+});
+server.listen(9999);
+
+
+var client = net.connect({ port : 9999 }, function() {
+    fs.createReadStream(file).pipe(client);
+});

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