fit(windowStart, windowEnd, isNew = false) {
    goog.asserts.assert(windowEnd != null,
        'Content duration must be known for static content!');
    goog.asserts.assert(windowEnd != Infinity,
        'Content duration must be finite for static content!');
    if (this.immutable_) {
      return;
    }

    // Trim out references we will never use.
    while (this.references.length) {
      const lastReference = this.references[this.references.length - 1];
      if (lastReference.startTime >= windowEnd) {
        this.references.pop();
      } else {
        break;
      }
    }

    while (this.references.length) {
      const firstReference = this.references[0];
      if (firstReference.endTime <= windowStart) {
        this.references.shift();
        if (!isNew) {
          this.numEvicted_++;
        }
      } else {
        break;
      }
    }

    if (this.references.length == 0) {
      return;
    }

    // Adjust the last SegmentReference.
    const lastReference = this.references[this.references.length - 1];
    const newReference = new shaka.media.SegmentReference(
        lastReference.startTime,
        /* endTime= */ windowEnd,
        lastReference.getUrisInner,
        lastReference.startByte,
        lastReference.endByte,
        lastReference.initSegmentReference,
        lastReference.timestampOffset,
        lastReference.appendWindowStart,
        lastReference.appendWindowEnd,
        lastReference.partialReferences,
        lastReference.tilesLayout,
        lastReference.tileDuration,
        lastReference.syncTime,
        lastReference.status,
        lastReference.aesKey,
    );
    newReference.mimeType = lastReference.mimeType;
    newReference.codecs = lastReference.codecs;
    newReference.discontinuitySequence = lastReference.discontinuitySequence;
    this.references[this.references.length - 1] = newReference;
  }
Drops references that start after windowEnd, or end before windowStart,
and contracts the last reference so that it ends at windowEnd.

Do not call on the last period of a live presentation (unknown duration).
It is okay to call on the other periods of a live presentation, where the
duration is known and another period has been added.

@param {number} windowStart
@param {?number} windowEnd
@param {boolean=} isNew Whether this is a new SegmentIndex and we shouldn't
  update the number of evicted elements.
@export