transformByteStream<T> function

Stream<T> transformByteStream<T>(
  1. Stream<List<int>> rawStream,
  2. ByteStreamTransformer<T> builder
)

Byte stream builder Use DataReader to handle byte data, and transform to specified type data For example:

Stream<List

void main() { transformByteStream(testStream(), (dataReader) { return dataReader.readInt(); }).listen(print); }

Output:

256 1

Implementation

Stream<T> transformByteStream<T>(Stream<List<int>> rawStream, ByteStreamTransformer<T> builder) async* {
	final reader = DataReader(ByteBufferReader(StreamReader(rawStream)));
	while (!reader.isEnd) {
		final transformedData = await builder(reader);
		yield transformedData;
	}
}