-
-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: Add Squash operation #83
Conversation
2424ef3
to
a10e2ab
Compare
Ready for another review. |
@@ -712,6 +712,11 @@ public function split(int $type = Operation\Splitable::BEFORE, callable ...$call | |||
return new self(Split::of()($type)(...$callbacks), $this->getIterator()); | |||
} | |||
|
|||
public function squash(): CollectionInterface | |||
{ | |||
return self::fromIterable($this->pack()->all())->unpack(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you need I can help adding the docs for this method, but would just like to understand a bit better how this works. I'm looking at the docs for pack
and unpack
but still don't get why they're needed here 😓.
If you don't mind can you explain what's the difference between this and doing the below?
return self::fromIterable($this->all());
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suspect it has to do with the collections allowing keys that are not only int|string
as well as duplicate keys, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes exactly. iterator_to_array()
will fail if keys are different from int|string
.
Ready for the last review! |
1141c77
to
80659f7
Compare
80659f7
to
34020ae
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for working on this so quickly! 🚀
This PR
Follows #82.
Related to #80.
Fixes #80.