Skip to content

Commit

Permalink
Update Walk operation.
Browse files Browse the repository at this point in the history
  • Loading branch information
drupol committed May 26, 2020
1 parent 7376353 commit be33b49
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/Operation/Walk.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,12 @@ public function on(iterable $collection): Closure

return static function () use ($callbacks, $collection): Generator {
foreach ($collection as $key => $value) {
$carry = $value;

// Custom array_reduce function with the key passed in argument.
foreach ($callbacks as $callback) {
$carry = $callback($carry, $key);
$value = $callback($value, $key);
}

yield $key => $carry;
yield $key => $value;
}
};
}
Expand Down

0 comments on commit be33b49

Please sign in to comment.