Skip to content

Commit

Permalink
Merge pull request #53 from shinayser/adding-iterable-stream
Browse files Browse the repository at this point in the history
Adding asStream
  • Loading branch information
passsy committed Feb 5, 2020
2 parents 7524b64 + 7185478 commit 90193c6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/src/iterable.dart
Expand Up @@ -922,6 +922,9 @@ extension IterableX<E> on Iterable<E> {
yield* this;
}

/// Returns a new [Stream] with all elements of this collection.
Stream<E> asStream() => Stream.fromIterable(this);

/// Returns a new [HashSet] with all distinct elements of this collection.
HashSet<E> toHashSet() => HashSet.from(this);

Expand Down
5 changes: 5 additions & 0 deletions test/iterable_test.dart
Expand Up @@ -609,6 +609,11 @@ void main() {
);
});

test('.asStream()', () {
expect([0, 1, 2, 3, 4, 5].asStream(), emitsInOrder([0, 1, 2, 3, 4, 5]));
expect([100, 99, 98, 95].asStream(), emitsInOrder([100, 99, 98, 95]));
});

test('.flatten()', () {
expect([].flatten(), []);

Expand Down

0 comments on commit 90193c6

Please sign in to comment.