fast-deep-equal icon indicating copy to clipboard operation
fast-deep-equal copied to clipboard

Break cycles

Open mindplay-dk opened this issue 7 years ago • 4 comments

Comparing two object graphs with cycles sends this library into recursive tail-spin.

Having tested for this issue with both deep-equal, fast-deep-equal and deep-eql, I found that the only library where this works, is deep-eql, so you might consider referencing their approach.

If you don't wish to support object graphs with cycles, perhaps this should be explicitly omitted and noted in the documentation, since it creates pretty serious issues in test-frameworks etc.?

mindplay-dk avatar Apr 17 '18 15:04 mindplay-dk

I don't mind supporting cycles with some extra option, as long as it doesn't affect performance in the main use case (it can be difficult though). Documenting would definitely be helpful.

You could try using https://www.npmjs.com/package/cyclical-json but you will need to fork to create stable order for keys.

epoberezkin avatar Apr 17 '18 20:04 epoberezkin

I ended up using deep-eql - I was just reporting the issue to make it known, like a good citizen ;-)

mindplay-dk avatar Apr 18 '18 06:04 mindplay-dk

In branch cycles

epoberezkin avatar Jul 07 '19 18:07 epoberezkin

In branch cycles

would be cool to have this feature! do you consider doing a pull request?

macrozone avatar Feb 16 '20 14:02 macrozone