splitFrom<T> method

List<Stream<T>> splitFrom <T>(Stream<T> stream, [ int count ])

Splits stream into count identical streams.

count defaults to 2. This is the same as creating count branches and then closing the StreamSplitter.

Implementation

static List<Stream<T>> splitFrom<T>(Stream<T> stream, [int count]) {
  if (count == null) count = 2;
  var splitter = new StreamSplitter<T>(stream);
  var streams = new List<Stream<T>>.generate(count, (_) => splitter.split());
  splitter.close();
  return streams;
}