-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
fix(3232): fix R.groupBy when used as transducer #3234
Conversation
While I did submit quick-and-dirty fix, I think yours might actually be better - I think the problem is that transducers are inherently stateful (especially in the step function), they just happen to hide the state under the hood (this being a huge optimization in clojure, or in JS using I don't know this codebase super well, but if I had to guess, I think your fix could end up solving similar issues if there are other "also usable as a transducer" reductions that aren't being tested in transducer form. Other JS implementations of transduce, I usually see this handled by the final transform created by e.g. |
Ok, I'm gonna open the PR because my solution seems more consistent with the no-transducers implementation. After reading what you say, @jaawerth, I don't like to much the _clone approach we have in functions like |
I am having a busy week so worse case scenario I'm going to look at this over the weekend. But thank you both for coordinating your efforts. It's great to see 🙇♂️ |
Sorry for introduce the bug, I wll see what happen here, |
I spend some time to see the source code of When using var groupBy = _curry2(_checkForMethod('groupBy', reduceBy(function(acc, item) {
if (acc == null) {
acc = [];
}
acc.push(item);
return acc;
}, null))); when |
When I change the source code to: var groupBy = _curry2(_checkForMethod('groupBy', reduceBy(function(acc, item) {
acc.push(item);
return acc;
}, [])));
Because when process data directly, it will |
All other Ramda apis base on var countBy = reduceBy(function(acc, elem) { return acc + 1; }, 0);
var indexBy = reduceBy(function(acc, elem) { return elem; }, null); |
Sorry again for introducing this bug. Both this pr and @jaawerth 's pr will fix the bug, and this pr will be better in my opinion, because it unifies the direct data procedure and transducer behavior. |
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 very much. This looks great!
It fixes #3232