| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library pub_semver.src.utils; | |
| 6 | |
| 7 import 'version_range.dart'; | 5 import 'version_range.dart'; |
| 8 | 6 |
| 9 /// Returns whether [range1] is immediately next to, but not overlapping, | 7 /// Returns whether [range1] is immediately next to, but not overlapping, |
| 10 /// [range2]. | 8 /// [range2]. |
| 11 bool areAdjacent(VersionRange range1, VersionRange range2) { | 9 bool areAdjacent(VersionRange range1, VersionRange range2) { |
| 12 if (range1.max != range2.min) return false; | 10 if (range1.max != range2.min) return false; |
| 13 | 11 |
| 14 return (range1.includeMax && !range2.includeMin) || | 12 return (range1.includeMax && !range2.includeMin) || |
| 15 (!range1.includeMax && range2.includeMin); | 13 (!range1.includeMax && range2.includeMin); |
| 16 } | 14 } |
| 17 | 15 |
| 18 /// A [Comparator] that compares the maximum versions of [range1] and [range2]. | 16 /// A [Comparator] that compares the maximum versions of [range1] and [range2]. |
| 19 int compareMax(VersionRange range1, VersionRange range2) { | 17 int compareMax(VersionRange range1, VersionRange range2) { |
| 20 if (range1.max < range2.max) return -1; | 18 if (range1.max < range2.max) return -1; |
| 21 if (range1.max > range2.max) return 1; | 19 if (range1.max > range2.max) return 1; |
| 22 | 20 |
| 23 if (!range1.includeMax && range2.includeMax) return -1; | 21 if (!range1.includeMax && range2.includeMax) return -1; |
| 24 if (range1.includeMax && !range2.includeMax) return 1; | 22 if (range1.includeMax && !range2.includeMax) return 1; |
| 25 return 0; | 23 return 0; |
| 26 } | 24 } |
| OLD | NEW |