Skip to content

Commit

Permalink
Use FilterIterableAggregate.
Browse files Browse the repository at this point in the history
  • Loading branch information
drupol committed Jun 24, 2022
1 parent 6cdf7fb commit 84b42c2
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/Operation/Filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Closure;
use Generator;
use loophp\collection\Utils\CallbacksArrayReducer;
use loophp\iterators\FilterIterableAggregate;

/**
* @immutable
Expand Down Expand Up @@ -55,11 +56,7 @@ static function (iterable $iterable) use ($callbacks): Generator {

$callback = CallbacksArrayReducer::or()($callbacks);

foreach ($iterable as $key => $current) {
if ($callback($current, $key, $iterable)) {
yield $key => $current;
}
}
yield from new FilterIterableAggregate($iterable, $callback);
};
}
}

0 comments on commit 84b42c2

Please sign in to comment.