Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(144)

Side by Side Diff: lib/src/utils.dart

Issue 1127783002: Add more set-like version constraint operations. (Closed) Base URL: git@github.com:dart-lang/pub_semver@master
Patch Set: Code review changes Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 }
OLDNEW
« no previous file with comments | « CHANGELOG.md ('k') | lib/src/version.dart » ('j') | lib/src/version_range.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698