Skip to content
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

default compare function bug #2

Open
mixmix opened this issue Feb 17, 2022 · 2 comments
Open

default compare function bug #2

mixmix opened this issue Feb 17, 2022 · 2 comments

Comments

@mixmix
Copy link
Member

mixmix commented Feb 17, 2022

function cmp (a, b) {
  return a < b ? -1 : a > b ? 1 : 0
}

merge seems to choke if the return value is 0

solution change the default to fall back to e.g. 1 (or oscillate between 1/ -1)

@mixmix
Copy link
Member Author

mixmix commented Feb 17, 2022

Oh I went to write a test for this and in reading the source code found it was dropping values (which was a surprise!)

https://github.com/pull-stream/pull-merge/pull/3/files
This PR makes the README clearer

@regular
Copy link

regular commented Nov 20, 2023

@mixmix is this why we also have pull-merge-sorted? I just had a long debug session revealing that this module was to blame (one source stream at some point was ignored forever, without compare ever returning 0). Switching to merge-sorted fixed it. Wasn't able to isolate the problem yet or make a test. Just wanted to share in case it helps someone out there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants