resolve method
- int length
Resolves the slice against a length and returns (from, to), or
null when the range fails to match. Mirrors go-ipld-prime
sliceBounds.
Implementation
(int, int)? resolve(int length) {
var to = this.to;
var from = this.from;
if (to < 0) {
to = length + to;
} else if (length < to) {
to = length;
}
if (from < 0) {
from = length + from;
if (from < 0) from = 0;
}
if (from > to || from >= length) return null;
return (from, to);
}