assertCanSeek(index) {
    const state = this.#state;
    if (!this.canSeek(index)) {
      const err = Error(
        `End of data reached (data length = ${state.length}, asked index ${index}`,
      );
      // @ts-expect-error
      err.code = 'EOD';
      // @ts-expect-error
      err.index = index;
      throw err;
    }
  }
@param {number} index the index to check.
@throws {Error} an Error if the index is out of bounds.