src/Interval.js
function(that) {
    if (this.sourceString !== that.sourceString) {
      throw errors.intervalSourcesDontMatch();
    } else if (this.startIdx === that.startIdx && this.endIdx === that.endIdx) {
      // `this` and `that` are the same interval!
      return [
      ];
    } else if (this.startIdx < that.startIdx && that.endIdx < this.endIdx) {
      // `that` splits `this` into two intervals
      return [
        new Interval(this.sourceString, this.startIdx, that.startIdx),
        new Interval(this.sourceString, that.endIdx, this.endIdx)
      ];
    } else if (this.startIdx < that.endIdx && that.endIdx < this.endIdx) {
      // `that` contains a prefix of `this`
      return [
        new Interval(this.sourceString, that.endIdx, this.endIdx)
      ];
    } else if (this.startIdx < that.startIdx && that.startIdx < this.endIdx) {
      // `that` contains a suffix of `this`
      return [
        new Interval(this.sourceString, this.startIdx, that.startIdx)
      ];
    } else {
      // `that` and `this` do not overlap
      return [
        this
      ];
    }
  }
function(that) {
    if (this.sourceString !== that.sourceString) {
      throw errors.intervalSourcesDontMatch();
    } else if (this.startIdx === that.startIdx && this.endIdx === that.endIdx) {
      // `this` and `that` are the same interval!
      return [
      ];
    } else if (this.startIdx < that.startIdx && that.endIdx < this.endIdx) {
      // `that` splits `this` into two intervals
      return [
        new Interval(this.sourceString, this.startIdx, that.startIdx),
        new Interval(this.sourceString, that.endIdx, this.endIdx)
      ];
    } else if (this.startIdx < that.endIdx && that.endIdx < this.endIdx) {
      // `that` contains a prefix of `this`
      return [
        new Interval(this.sourceString, that.endIdx, this.endIdx)
      ];
    } else if (this.startIdx < that.startIdx && that.startIdx < this.endIdx) {
      // `that` contains a suffix of `this`
      return [
        new Interval(this.sourceString, this.startIdx, that.startIdx)
      ];
    } else {
      // `that` and `this` do not overlap
      return [
        this
      ];
    }
  }
function ( that ) { if ( this . sourceString !== that . sourceString ) { throw errors . intervalSourcesDontMatch ( ) ; } else if ( this . startIdx === that . startIdx && this . endIdx === that . endIdx ) { // `this` and `that` are the same interval! return [ ] ; } else if ( this . startIdx < that . startIdx && that . endIdx < this . endIdx ) { // `that` splits `this` into two intervals return [ new Interval ( this . sourceString , this . startIdx , that . startIdx ) , new Interval ( this . sourceString , that . endIdx , this . endIdx ) ] ; } else if ( this . startIdx < that . endIdx && that . endIdx < this . endIdx ) { // `that` contains a prefix of `this` return [ new Interval ( this . sourceString , that . endIdx , this . endIdx ) ] ; } else if ( this . startIdx < that . startIdx && that . startIdx < this . endIdx ) { // `that` contains a suffix of `this` return [ new Interval ( this . sourceString , this . startIdx , that . startIdx ) ] ; } else { // `that` and `this` do not overlap return [ this ] ; } }
Returns an array of 0, 1, or 2 intervals that represents the result of the interval difference operation.
Returns an array of 0 1 or 2 intervals that represents the result of the interval difference operation .