Skip to content

Commit

Permalink
🔥 Remove elementAtOrNull extension.
Browse files Browse the repository at this point in the history
  • Loading branch information
BirjuVachhani committed Oct 20, 2022
1 parent 401c4ef commit ec4f3f3
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 13 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## 3.1.1

- Fix `MAX_INT_VALUE` and `MIN_INT_VALUE` not compiling for JS.
- [BREAKING]: Remove `elementAtOrNull` since it is added in the `collections` package.
- Upgrade dependencies.

## 3.1.0
Expand Down
7 changes: 0 additions & 7 deletions lib/collection/iterable.dart
Original file line number Diff line number Diff line change
Expand Up @@ -417,13 +417,6 @@ extension IterableScrewDriver<E> on Iterable<E> {
/// Alias for [subtract].
Iterable<E> except(Iterable<E> other) => subtract(other);

/// Equivalent to [elementAt] but returns null instead of throwing
/// [RangeError] if the index is out of bounds.
E? elementAtOrNull(int index) {
if (index < 0 || index >= length) return null;
return elementAt(index);
}

/// Returns true if the collection contains all the elements
/// present in [other] collection.
bool containsAll(Iterable<E> other) => other.every(contains);
Expand Down
6 changes: 0 additions & 6 deletions test/iterable_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,6 @@ void main() {
expect([1, 2, 3].except([2]), containsAllInOrder(<int>[1, 3]));
expect([1, 2, 3].except([1, 5]), containsAllInOrder(<int>[2, 3]));

// elementAtOrNull tests
expect([1, 2, 3].elementAtOrNull(0), equals(1));
expect([1, 2, 3].elementAtOrNull(2), equals(3));
expect([1, 2, 3].elementAtOrNull(3), isNull);
expect([1, 2, 3].elementAtOrNull(-1), isNull);

// containsAll tests
expect([1, 2, 3].containsAll([1, 2]), isTrue);
expect([1, 2, 3].containsAll([1, 2, 3, 4]), isFalse);
Expand Down

0 comments on commit ec4f3f3

Please sign in to comment.