skipUntil method

void skipUntil(
  1. int condition(), [
  2. bool allowEof = false
])

Skip until condition returns a value equal to or below 0. Throws an exception if condition returns 0. Increments by condition().abs().

Implementation

void skipUntil(int Function() condition, [bool allowEof = false]) {
	while (inBounds) {
		// call condition
		var value = condition();
		seek(value.abs());
		// stop seeking
		if (value <= 0) {
			return;
		}
	}
	// throw an error if we've reached eof and aren't allowed to
	if (!allowEof) {
		throw "skipUntil reached eof but allowEof is false (${getLineCol()})";
	}
}