DoneDeal0 / superdiff

Superdiff compares two arrays or objects and returns a full diff of their differences in a readable format.
https://www.npmjs.com/package/@donedeal0/superdiff
439 stars 3 forks source link

fix: resolve cases when comparing arrays to non-array values #18

Closed mfactorial closed 2 months ago

mfactorial commented 2 months ago

Today, I encountered a bug while comparing two objects using getObjectDiff. In the prevData object, a property had an array value, while in the nextData object, the same property had a non-array value. The isEqual function failed because it only checks if value a is an array. If a is an array, it attempts to get the length of value b, which causes an error when b is not an array.

This fix ensures that the comparison logic correctly handles cases where an array is compared to a non-array value, preventing such errors.

DoneDeal0 commented 2 months ago

Well spotted @mfactorial ! Thank you very much for your pull request!

ps: I will publish a new release when #19 is fixed, so we only bump the lib once.