[Pkg-javascript-commits] [node-jsonstream] 21/214: also check for 0 events in stringify()
Bastien Roucariès
rouca at moszumanska.debian.org
Fri Dec 1 12:58:33 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 78023fbaae89dbf6e840569f7e20f80de0d6a154
Author: James Halliday <mail at substack.net>
Date: Wed Feb 22 11:31:21 2012 -0800
also check for 0 events in stringify()
---
index.js | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/index.js b/index.js
index 96321ae..b2c8cd1 100644
--- a/index.js
+++ b/index.js
@@ -96,17 +96,19 @@ exports.stringify = function (op, sep, cl) {
var stream = new Stream ()
, first = true
, ended = false
+ , anyData = false
stream.write = function (data) {
var json = JSON.stringify(data)
if(first) { first = false ; stream.emit('data', op + json)}
else stream.emit('data', sep + json)
+ anyData = true
}
stream.end = function (data) {
if(ended)
return
ended = true
- if(data)
- stream.write(data)
+ if(data) stream.write(data)
+ if(!anyData) stream.write(op)
stream.emit('data', cl)
stream.emit('end')
--
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