inspect-js / node-deep-equal

node's assert.deepEqual algorithm
MIT License
778 stars 109 forks source link

Support for comparing arrays by members without order (set equality) #93

Closed t3hmrman closed 3 years ago

t3hmrman commented 3 years ago

Would it be possible to offer an option to compare arrays by members rather than members+order? This is a weaker concept of equality but is sometimes useful when dealing with non-deterministically produced arrays.

I'm pretty sure the change would one or a few lines above the existing array case, but want to at least start the discussion first.

ljharb commented 3 years ago

This module largely matches node's assert deep equality APIs - https://nodejs.org/api/assert.html#assert_assert_deepequal_actual_expected_message - which don't have an option to compare arrays unordered.

I think the first thing to try would be to see if node core will accept such an option.

vados-xenon commented 3 years ago

Ah that's reasonable -- it probably doesn't make sense to add it here then until it's there, maybe this ticket could be reopened if/when that's considered

ljharb commented 3 years ago

That sounds like a good plan. Please link the node core issue/PR here once you've filed it :-)