return Promise.reject(new CancellationError());
}
// If trying to resolve the sentinel item, load next page
if (index === this.items.length && this._hasNextPage) {
await this.loadNextPage(cancellationToken);
}
// After loading, the requested index should now be valid
if (index < this.items.length) {
return this.items[index];
}
throw new Error('Index out of bounds');