fast-equals icon indicating copy to clipboard operation
fast-equals copied to clipboard

Handle Error instances.

Open KenjiTakahashi opened this issue 2 years ago • 1 comments

AFAICT they behave pretty much like regular objects, except that they have a tag of [object Error]. At the moment, they seem to fall through all the checks and just return false, without actually comparing anything.

KenjiTakahashi avatar Mar 26 '24 13:03 KenjiTakahashi

Sure, I can add support for that tag. To-date they have been treated as reference equality, since there didn't seem to be a use-case to do even a shallow equality comparison, but easy enough to add.

planttheidea avatar Sep 14 '24 18:09 planttheidea

It looks like standard object comparison doesn't work because the properties are not enumerable, however the properties on error instances are known and primitive values (much like regexp) so a custom comparator is easy enough.

planttheidea avatar Jan 03 '25 16:01 planttheidea

Has been resolved as-of 5.1.0, as you can use the new areErrorsEqual method in a custom equality config.

planttheidea avatar Jan 03 '25 18:01 planttheidea