epoberezkin / fast-deep-equal

The fastest deep equality check with Date, RegExp and ES6 Map, Set and typed arrays support
MIT License
1.88k stars 101 forks source link

Add support for WeakMap, WeakSet and Promise #53

Open fabiospampinato opened 4 years ago

fabiospampinato commented 4 years ago

As an example the following returns true, instead it should return false:

require ( 'fast-deep-equal/es6' )( new WeakMap (), new WeakMap () )

I think this types of objects should be checked for strict equality.

illuminist commented 4 years ago

I believe WeakMap and WeakSet don't hold or have an ability to iterate their keys. So they just can't be compared.

Had no idea about Promise equality though.

fabiospampinato commented 4 years ago

@illuminist they can't be deeply compared like objects, but you can check if they are the same object or not.

illuminist commented 4 years ago

Oh I see, I misread your explanation. Good day though.

epoberezkin commented 4 years ago

@fabiospampinato That is a breaking change, but it makes sense to not just iterate their properties and only compare by reference. PR is welcome.