sub-stream
A simple-stream pull-filter for converting flat streams into nested streams.
subStream(stream, isHandle, propName) -> stream
Input is a flat stream that looks like header
, chunk
, chunk
, ..., header
, ...
In other words, you get header events followed by zero of more body chunks.
The output is a nested stream of headerWithSubStream
, headerWithSubStream
, ...
It's much easier to write filters that output flat streams than nested streams, especially when using the push-to-pull helper.
var subStream = ;var pushToPull = ; // This is a madeup stream that emits 0 to 9 and then ends.var stream = ; // A filter that takes in a number and then outputs {size:n} followed by n monkeys.var filter = ; // Create a nested stream using count, filter, and subStream.stream = ; // Consume the nested streamconsolelog;