Skip to content

Commit

Permalink
Add string comparisons
Browse files Browse the repository at this point in the history
  • Loading branch information
Pante committed Sep 25, 2023
1 parent c221f6c commit e873010
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 179 deletions.
4 changes: 2 additions & 2 deletions sugar/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## 3.2.0 (Next)
## 4.0.0 (Next)

## `sugar.collection`
- Add `Lists.toggleAll(...)`
Expand All @@ -8,7 +8,7 @@
- Add `System.epochMilliseconds`
- Add `System.epochMicroseconds`
- **Breaking** - Change `Runtime` to `System`
- Deprecate `Maybe` extension for removal in Sugar 3.3.0.
- **Breaking** - Remove `Maybe` extension.
- Remove `Iterables.indexed` since it already exists in Dart 3.

## `sugar.time`
Expand Down
1 change: 0 additions & 1 deletion sugar/lib/core.dart
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ export 'src/core/comparables.dart';
export 'src/core/disposable.dart';
export 'src/core/equality.dart';
export 'src/core/functions.dart';
export 'src/core/maybe.dart';
export 'src/core/result.dart';
export 'src/core/string_buffers.dart';
export 'src/core/strings.dart';
131 changes: 0 additions & 131 deletions sugar/lib/src/core/maybe.dart

This file was deleted.

77 changes: 77 additions & 0 deletions sugar/lib/src/core/strings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -408,4 +408,81 @@ extension Strings on String {
/// See [isBlank].
@useResult bool get isNotBlank => trim().isNotEmpty;


/// Returns whether this string is lexicographically less than [other].
///
/// If one string is a prefix of the other, then the shorter string is less than the longer string. This function does
/// not check for Unicode equivalence and is case sensitive.
///
/// ```dart
/// 'A' < 'B'; // true
/// 'B < A'; // false
///
/// 'A' < 'A'; // false
///
/// 'A' < 'Apple'; // true
/// 'Apple' < 'A'; // false
///
/// 'a' < 'A'; // true
/// 'A' < 'a'; // false
/// ```
bool operator < (String other) => compareTo(other) < 0;

/// Returns whether this string is lexicographically less than or equal to [other].
///
/// If one string is a prefix of the other, then the shorter string is less than the longer string. This function does
/// not check for Unicode equivalence and is case sensitive.
///
/// ```dart
/// 'A' <= 'B'; // true
/// 'B <= A'; // false
///
/// 'A' <= 'A'; // true
///
/// 'A' <= 'Apple'; // true
/// 'Apple' <= 'A'; // false
///
/// 'a' <= 'A'; // true
/// 'A' <= 'a'; // false
/// ```
bool operator <= (String other) => compareTo(other) <= 0;

/// Returns whether this string is lexicographically greater than [other].
///
/// If one string is a prefix of the other, then the larger string is greater than the shorter string. This function
/// does not check for Unicode equivalence and is case sensitive.
///
/// ```dart
/// 'B > A'; // true
/// 'A' > 'B'; // false
///
/// 'A' > 'A'; // false
///
/// 'Apple' > 'A'; // true
/// 'A' > 'Apple'; // false
///
/// 'A' > 'a'; // true
/// 'a' > 'A'; // false
/// ```
bool operator > (String other) => compareTo(other) > 0;

/// Returns whether this string is lexicographically greater than or equal to [other].
///
/// If one string is a prefix of the other, then the larger string is greater than the shorter string. This function
/// does not check for Unicode equivalence and is case sensitive.
///
/// ```dart
/// 'B >= A'; // true
/// 'A' >= 'B'; // false
///
/// 'A' >= 'A'; // true
///
/// 'Apple' >= 'A'; // true
/// 'A' >= 'Apple'; // false
///
/// 'A' >= 'a'; // true
/// 'a' >= 'A'; // false
/// ```
bool operator >= (String other) => compareTo(other) >= 0;

}
45 changes: 0 additions & 45 deletions sugar/test/src/core/maybe_test.dart

This file was deleted.

0 comments on commit e873010

Please sign in to comment.