Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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

  • Loading branch information...
commit 20d260b842ca3bf95210fd88266ae7f66db1c9ef 1 parent 4d0684b
James Halliday authored

Showing 2 changed files with 6 additions and 6 deletions. Show diff stats Hide diff stats

  1. +5 5 index.js
  2. +1 1  test/stringify_object.js
10 index.js
@@ -135,17 +135,17 @@ exports.stringifyObject = function (op, sep, cl) {
135 135 var stream = new Stream ()
136 136 , first = true
137 137 , ended = false
138   - stream.write = function (key, data) {
139   - var json = JSON.stringify(key) + ':' + JSON.stringify(data)
  138 + stream.write = function (data) {
  139 + var json = JSON.stringify(data[0]) + ':' + JSON.stringify(data[1])
140 140 if(first) { first = false ; stream.emit('data', op + json)}
141 141 else stream.emit('data', sep + json)
142 142 }
143   - stream.end = function (key, data) {
  143 + stream.end = function (data) {
144 144 if(ended)
145 145 return
146 146 ended = true
147   - if(key !== undefined)
148   - stream.write(key, data)
  147 + if(data)
  148 + stream.write(data)
149 149 stream.emit('data', cl)
150 150
151 151 stream.emit('end')
2  test/stringify_object.js
@@ -37,7 +37,7 @@ es.connect(
37 37 while (count --) {
38 38 var key = Math.random().toString(16).slice(2)
39 39 expected[key] = randomObj()
40   - stringify.write(key, expected[key])
  40 + stringify.write([ key, expected[key] ])
41 41 }
42 42
43 43 stringify.end()

0 comments on commit 20d260b

Please sign in to comment.
Something went wrong with that request. Please try again.