[Pkg-javascript-commits] [node-jsonstream] 17/214: write() a single data array with [key, data] to make it easier to stream

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 20d260b842ca3bf95210fd88266ae7f66db1c9ef
Author: James Halliday <mail at substack.net>
Date:   Wed Feb 22 08:03:54 2012 -0800

    write() a single data array with [key,data] to make it easier to stream
---
 index.js                 | 10 +++++-----
 test/stringify_object.js |  2 +-
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/index.js b/index.js
index 210b454..92144f3 100644
--- a/index.js
+++ b/index.js
@@ -135,17 +135,17 @@ exports.stringifyObject = function (op, sep, cl) {
   var stream = new Stream ()
     , first = true
     , ended = false
-  stream.write = function (key, data) {
-    var json = JSON.stringify(key) + ':' + JSON.stringify(data)
+  stream.write = function (data) {
+    var json = JSON.stringify(data[0]) + ':' + JSON.stringify(data[1])
     if(first) { first = false ; stream.emit('data', op + json)}
     else stream.emit('data', sep + json)
   }
-  stream.end = function (key, data) {
+  stream.end = function (data) {
     if(ended)
       return
     ended = true
-    if(key !== undefined)
-      stream.write(key, data)
+    if(data)
+      stream.write(data)
     stream.emit('data', cl)
     
     stream.emit('end')
diff --git a/test/stringify_object.js b/test/stringify_object.js
index 873d231..b0de472 100644
--- a/test/stringify_object.js
+++ b/test/stringify_object.js
@@ -37,7 +37,7 @@ es.connect(
 while (count --) {
   var key = Math.random().toString(16).slice(2)
   expected[key] = randomObj()
-  stringify.write(key, expected[key])
+  stringify.write([ key, expected[key] ])
 }
 
 stringify.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