Node.js streams support for .pipe()
paramaggarwal opened this issue · comments
Param Aggarwal commented
Currently getMessages()
reads all the messages as fast as possible. I have a use case of processing this data and I would like to pause the reading of the bag while I process the messages that are already read.
By having a stream based API, I will be able to handle the entire processing pipeline as a Node.js stream.
Brian C commented
Yeah sounds reasonable - what type of API are you thinking? We'd still likely need the same config object passed to getMessages
passed to the stream constructor to make it an idiomatic node stream I believe.
For example:
// bagStream would be in objectMode: true
const bagStream = new RosbagStream({ topics: ['/foo', '/bar'], decompress }) // could support optional startTime & endTime as well
bagStream.pipe(through2(function (message) {
}))
Param Aggarwal commented