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

Extend the diff function with rich types not included in the base JS language. #40

Open
joshua-ds opened this issue Apr 15, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@joshua-ds
Copy link

❗ Is your feature request related to a problem? Please describe.
We use started using microdiff as a pre-step before doing db updates. When working with MongoDB, then use the ObjectId data type which is exported by the bson package to keep track of documents (records) and references between data.
It can be compared in JS using the toString() (or casting it to string).

However, currently microdiff compares it as an object and because the object has no properties (only methods), it can not identify the change.

✅ Describe the solution you'd like
In order for us to solve this issue and have microdiff detect changes to properties that are ObjectId, we needed to duplicate the function to our code base and extend the rich types object with the ObjectId: true property to have it trigger the "rich type" check and be evaluated as two strings being compared with each other.

↗️ Describe alternatives you've considered
I would recommend adding a property to the third argument of the function where cyclesFix can be passed in. This would be an object of extended rich types which then also need to be checked while calling the diff function.

➕ Additional context
Other data types in JS which have a compatible (to String) method of comparing them can be added to this and thus we can still use the microdiff library without having to duplicate the functionality.

@joshua-ds joshua-ds added the enhancement New feature or request label Apr 15, 2024
@joshua-ds joshua-ds changed the title ➕ Feature - [SHORT DESCRIPTION] ➕ Feature - Extend the diff function with rich types not included in the base JS language. Apr 15, 2024
@joshua-ds joshua-ds changed the title ➕ Feature - Extend the diff function with rich types not included in the base JS language. Extend the diff function with rich types not included in the base JS language. Apr 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant