clip(value) {
        if (this.isEmpty) {
            throw new BugIndicatingError(`Invalid clipping range: ${this.toString()}`);
        }
        return Math.max(this.start, Math.min(this.endExclusive - 1, value));
    }
Returns the given value if it is contained in this instance, otherwise the closest value that is contained.
The range must not be empty.