compare method

  1. @override
int compare (
  1. Node otherNode
)
override

Returns -1, 0 or +1

Implementation

@override
int compare(Node otherNode) {
  if (otherNode is! Dimension) return null;

  Dimension a;
  Dimension b;
  final Dimension other = otherNode;

  if (unit.isEmpty() || other.unit.isEmpty()) {
    a = this;
    b = other;
  } else {
    a = unify();
    b = other.unify();
    if (a.unit.compare(b.unit) != 0) return null;
  }

  return Node.numericCompare(a.value, b.value);

//2.3.1
//  Dimension.prototype.compare = function (other) {
//      var a, b;
//
//      if (!(other instanceof Dimension)) {
//          return undefined;
//      }
//
//      if (this.unit.isEmpty() || other.unit.isEmpty()) {
//          a = this;
//          b = other;
//      } else {
//          a = this.unify();
//          b = other.unify();
//          if (a.unit.compare(b.unit) !== 0) {
//              return undefined;
//          }
//      }
//
//      return Node.numericCompare(a.value, b.value);
//  };
}