Are you sure this is correct?  It *only* uses the offsets map if index is exactly two less than length.
So, assuming 5 objects, the first one would be `0 + 1 === 5 - 1` resolving to  `-20` when it should resolve to `offsets[0 + 1]`.