-
-
Notifications
You must be signed in to change notification settings - Fork 153
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
[@th.ing/transducer] weird behaviour when combining mapcat
with multiplex
#401
Comments
Thank you - for |
Awesome, thanks for the quick response 💪 This lib is a god send btw 🙏 |
Huston, we've got a problem... I've updated the code to disable unwrapping, but of course (in hindsight) all this has done is shifting the issue in the opposite way, i.e. in your above example from const xf = tx.multiplex(tx.mapcat((x) => x), tx.map((x) => x));
// new version of step with unwrapping of single results disabled
// (you wont' be able to reproduce this on your end yet...)
const xs=tx.step(xf, false);
xs([1, 2]);
// [ [ 1, 2 ], [ [ 1, 2 ] ] ]
xs([3]);
// [ [ 3 ], [ [ 3 ] ] ] As you can see, the issue now fixed for Will have to think about this some more... |
We could check if the result of a single item array with the item an array itself, but that's too fragile and will have a ton of edge cases. The only sure fire way would be to update the multiplex(
// provide as tuple to customize unwrap behavior
[mapcat((x) => x), false],
// or provide as before (with current unwrap behavior)
map((x) => x)
) IMHO that's the best/safest solution, also ensuring non-breaking behavior in existing userland code... |
The text was updated successfully, but these errors were encountered: