Suppose that there are no chunks. In this case, there would be no start positions or end positions, and the offsets array would be empty. This case terminates early because index < 0.

Suppose there is one chunk, [a, b). In this case, start positions would be [a], and the implied end positions would be [b], but b is unknown, and `offsets` would simply be [a], index would be 0, offsets.length would be 1. The expected end positions would be -20. `index + 1` would be 1, `offsets.length - 1` would be 0. `index + 1 === offsets.length - 1` would be false. Aggregate expression is `-20`.

Suppose there are two chunks. [a, b) and [b, c). Offsets would be [a, b] and c is unknown and presumed -20. `index + 1 === offsets.length - 1` for the first chunk is `0 + 1 === 2 - 1`, which is true, so we get `b`, which is correct. For the second chunk, `0 + 2 === 2 - 1` is false, so we get `-20`, also correct. This is the last case that works. Oops.

Suppose there are three chunks, [a, b), [b, c), [c, d), offsets would be [a, b, c], implied end positions are [b, c, d] and d is unknown and presumed -20. For the first index, the expected output is b. `0 + 1 === 3 - 1` is false, so it comes out to -20. Contradiction. However, `0 + 1 < 3` comes out correct. `0 + 2 < 3` comes out correct. `0 + 3 < 3` is false and produces the expected -20.

I’ll follow up with a patch.