montagejs / collections

This package contains JavaScript implementations of common data structures with idiomatic interfaces.
http://www.collectionsjs.com
Other
2.1k stars 183 forks source link

Backport improvments to equals and compare #61

Closed kriskowal closed 10 years ago

kriskowal commented 10 years ago

Using -Infinity and +Infinity instead of arbitrary -1 or 1 for string comparison prevents "viscinity checks", like, is this string near this other one, from getting confused.

Much less cleverness about comparing null and undefined so that polymorphic comparators get a chance to run if they exist.

Fixes for a bug in equals for same-shaped cyclic structures. Upon encountering a memo entry, return true and rely on the parent call to return false if the values are in fact inequal.

Avoid redundant equals calls in comparing object literals. Only compare object literals, not objects derriving from the same prototype.

Stuk commented 10 years ago

Fixes for a bug in equals for same-shaped cyclic structures. Upon encountering a memo entry, return true and rely on the parent call to return false if the values are in fact inequal.

Was most concerned by this but worked it through and I'm satisfied it's correct.