Skip to content

Commit

Permalink
fix: Update behavior of Apply operation.
Browse files Browse the repository at this point in the history
BREAKING CHANGE: yes
  • Loading branch information
drupol committed Jan 30, 2021
1 parent 5c76d76 commit e4fa034
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/Operation/Apply.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,17 @@ public function __invoke(): Closure
* @psalm-return Generator<TKey, T>
*/
static function (Iterator $iterator) use ($callbacks): Generator {
$continue = true;

foreach ($iterator as $key => $value) {
foreach ($callbacks as $callback) {
if (true === $callback($value, $key)) {
continue;
}
if ($continue !== false) {
foreach ($callbacks as $callback) {
if (true === $continue = $callback($value, $key)) {
continue;
}

break;
$continue = false;
}
}

yield $key => $value;
Expand Down

0 comments on commit e4fa034

Please sign in to comment.