scanTo method

Future<bool> scanTo(
  1. Matcher<XmlEvent> match
)

Scan the current queue for a match, reverting the queue if not found.

If found, the first element is the match. Leaves the queue untouched if not found.

match Function that returns true when found.

Implementation

Future<bool> scanTo(Matcher match) async {
  return withTransaction((queue) async {
    while (await queue.hasNext) {
      try {
        if (match(await queue.peek)) return true;
      } catch (e) {
        _log.fine(e);
        return false;
      }
      await queue.next;
    }
    return false;
  });
}