dominictarr / JSONStream

rawStream.pipe(JSONStream.parse()).pipe(streamOfObjects)
Other
1.91k stars 165 forks source link

Trouble with stringify... #155

Open ccorcos opened 6 years ago

ccorcos commented 6 years ago

I'm simply trying to log the output of the JSONStream from the Node REPL:

JSONStream = require("JSONStream")

logOut = new stream.Writable({
    write(chunk, encoding, done) {
        console.log(chunk, encoding, typeof chunk)
        done()
    }
})

stringify = JSONStream.stringify()

stringify.pipe(logOut)

stringify.push({hey: '1', b: [1,2,3,4]})

I get this error when I call .push at the bottom there:

TypeError: Invalid non-string/buffer chunk
    at validChunk (_stream_writable.js:254:10)
    at Writable.write (_stream_writable.js:288:21)
    at Stream.ondata (internal/streams/legacy.js:16:26)
    at emitOne (events.js:115:13)
    at Stream.emit (events.js:210:7)
    at drain (/Users/chet/Code/notion-next/node_modules/through/index.js:36:16)
    at Stream.stream.queue.stream.push (/Users/chet/Code/notion-next/node_modules/through/index.js:45:5)
    at repl:1:11
    at ContextifyScript.Script.runInThisContext (vm.js:50:33)
    at REPLServer.defaultEval (repl.js:240:29)