parseWith<R> method

  1. @useResult
Stream<R> parseWith<R>(
  1. Parser<R> parser, {
  2. ParseMatchCallback<R>? onMatch,
  3. ParseErrorCallback? onError,
  4. ParseCloseCallback? onClose,
})

Parses this stream of strings using parser.

Delegates to StreamParserExtension.parseStreamChunks.

For example:

final parser = letter().plus().flatten().trim();
final stream = Stream.fromIterable(['foo ', 'bar']);
final results = await stream.parseWith(parser).toList();
print(results); // ['foo', 'bar']

Implementation

@useResult
Stream<R> parseWith<R>(
  Parser<R> parser, {
  ParseMatchCallback<R>? onMatch,
  ParseErrorCallback? onError,
  ParseCloseCallback? onClose,
}) => parser.parseStreamChunks(
  this,
  onMatch: onMatch,
  onError: onError,
  onClose: onClose,
);