clampCount method

int clampCount(
  1. int offset,
  2. int count
)

Implementation

int clampCount(int offset, int count) {
  if (offset < 0 || offset > length) throw UDocParseException("Offset $offset outside 0..$length");
  if (count < 0) throw const UDocParseException("Negative read length");
  final int available = length - offset;
  return count > available ? available : count;
}