relativize<TT> method

JsonPath<TT> relativize<TT>(
  1. JsonPath other
)

Implementation

JsonPath<TT> relativize<TT>(JsonPath<dynamic> other) {
  final segments = <String>[];
  final i = this.segments.iterator;
  final i2 = other.segments.iterator;
  bool matches = true;
  while (i.moveNext()) {
    if (matches && i2.moveNext()) {
      if (i.current == i2.current) {
        continue;
      } else {
        matches = false;
      }
    }

    segments.add(i.current);
  }

  return JsonPath<TT>.segments(segments);
}