OLD | NEW |
(Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 library pub_semver.src.utils; |
| 6 |
| 7 import 'version_range.dart'; |
| 8 |
| 9 /// Returns whether [range1] is immediately next to, but not overlapping, |
| 10 /// [range2]. |
| 11 bool areAdjacent(VersionRange range1, VersionRange range2) { |
| 12 if (range1.max != range2.min) return false; |
| 13 |
| 14 return (range1.includeMax && !range2.includeMin) || |
| 15 (!range1.includeMax && range2.includeMin); |
| 16 } |
| 17 |
| 18 /// A [Comparator] that compares the maximum versions of [range1] and [range2]. |
| 19 int compareMax(VersionRange range1, VersionRange range2) { |
| 20 if (range1.max < range2.max) return -1; |
| 21 if (range1.max > range2.max) return 1; |
| 22 |
| 23 if (!range1.includeMax && range2.includeMax) return -1; |
| 24 if (range1.includeMax && !range2.includeMax) return 1; |
| 25 return 0; |
| 26 } |
OLD | NEW |