dominictarr / JSONStream

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

Emitting an event signalling the end of processing the stream #132

Closed prabathabey closed 7 years ago

prabathabey commented 7 years ago

I use JSONStream to parse incoming data in a simple gateway application. The incoming data that this application responds to should adhere to a known format comprising a header, payload, etc. Further, at times, I want to make sure that a specific element exists in the incoming message so that, if it doesn't, I can then throw an error indicating an invalid message format. If I'm not mistaken, there's no straightforward way in the current implementation of JSONStream to implement the above as there's no mechanism to let the calling code know when stream processing is done. Therefore, I'm checking in too see if adding what's outlined in $subject makes sense or if there's any other workaround I could potentially use to get around the problem. If this does make sense, I'm happy to contribute with a PR too as the change is trivial and simple.

Your feedback is appreciated.

prabathabey commented 7 years ago

Closed the ticket as what's suggested above is doable even in the current implementation.