Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

write() a single data array with [key,data] to make it easier to stream

  • Loading branch information...
commit 20d260b842ca3bf95210fd88266ae7f66db1c9ef 1 parent 4d0684b
@substack authored
Showing with 6 additions and 6 deletions.
  1. +5 −5 index.js
  2. +1 −1  test/stringify_object.js
View
10 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')
View
2  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()
Please sign in to comment.
Something went wrong with that request. Please try again.