all files / model/ ContainerAddress.js

94.12% Statements 16/17
100% Branches 12/12
80% Functions 4/5
94.12% Lines 16/17
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40      341× 341×       238× 238× 49× 189× 116× 73× 29× 44× 22×   22× 19×           27×       31×                  
class ContainerAddress {
 
  constructor(pos, offset) {
    this.pos = pos
    this.offset = offset
  }
 
  isBefore(other, strict) {
    strict = Boolean(strict)
    if (this.pos < other.pos) {
      return true
    } else if (this.pos > other.pos) {
      return false
    } else if (this.offset < other.offset) {
      return true
    } else if (this.offset > other.offset) {
      return false
    }
    if (strict) {
      return false
    } else {
      return true
    }
  }
 
  isAfter(other, strict) {
    return other.isBefore(this, strict)
  }
 
  isEqual(other) {
    return (this.pos === other.pos && this.offset === other.offset)
  }
 
  toString() {
    return [this.pos,'.',this.offset].join('')
  }
}
 
export default ContainerAddress