parseStreamChunks method

  1. @useResult
Stream<R> parseStreamChunks(
  1. Stream<String> stream, {
  2. ParseMatchCallback<R>? onMatch,
  3. ParseErrorCallback? onError,
  4. ParseCloseCallback? onClose,
})

Parses chunks of text from stream into a progressive Stream of R.

See ParseDecoderSink for chunk-boundary behavior and callbacks.

For example:

final parser = seq3(char('<'), word().plus(), char('>')).flatten();
final chunks = Stream.fromIterable(['<al', 'pha><be', 'ta>']);
final results = await parser.parseStreamChunks(chunks).toList();
print(results); // ['<alpha>', '<beta>']

Implementation

@useResult
Stream<R> parseStreamChunks(
  Stream<String> stream, {
  ParseMatchCallback<R>? onMatch,
  ParseErrorCallback? onError,
  ParseCloseCallback? onClose,
}) => stream
    .transform(
      toConverter(onMatch: onMatch, onError: onError, onClose: onClose),
    )
    .expand((elements) => elements);