-
Notifications
You must be signed in to change notification settings - Fork 4
feat: expand types to allow differently typed arrays #156
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
feat: expand types to allow differently typed arrays #156
Conversation
With a comparator function, there's not a hard requirement for the two arrays to be compatible types. The comparator tells us whether they are "equal", and that's enough. This will maintain the integrity between which type corresponds to what in the comparators, as well as the functions where appropriate. This doesn't touch `getPatch` or `applyPatch`, because patching doesn’t make sense if the types don’t match.
I’m doing some work where I need to find the diff between a list of documents and a list of corresponding draft documents, which have different types in enough ways that it gets tedious to try to combine them into a shared interface. As stated in the description above, the functions that do the heavy lifting don’t actually require that the type between the two arrays be the same. This PR expands the types to allow that (while still providing a default for the second array's type so that the user could still provide a single type param if desired, making it a non-breaking change). Let me know what you think. |
@ericbf This is an excellent idea to make the diff support for different types of comparison! |
I can definitely add some test cases |
@ericbf Thanks very much for your contrbution! Everything looks perfect! |
# [1.1.0](v1.0.1...v1.1.0) (2023-03-21) ### Features * expand types to allow differently typed arrays ([#156](#156)) ([9da10de](9da10de))
🎉 This PR is included in version 1.1.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
# [1.1.0](v1.0.1...v1.1.0) (2023-03-21) ### Features * expand types to allow differently typed arrays ([#156](#156)) ([9da10de](9da10de))
With a comparator function, there’s not a hard requirement for the two arrays to be compatible types. The comparator tells us whether they are “equal”, and that’s enough. This will maintain the integrity between which type corresponds to what in the comparators, as well as the functions where appropriate.
This doesn’t touch
getPatch
orapplyPatch
, because patching doesn’t make sense if the types don’t match.Related to #90