Releases: shouldjs/should.js
13.1.3
13.1.2
13.1.1
13.1.0
13.0.1
13.0.0
Better Map Set equality
Map/Set/WeakMap/WeakSet equality checks
User @BridgeAR pointed to a number of bugs and inconcistency in Map/Set/WeakMap/WeakSet checks. To fix all this things, i switched map and set equality checks to do key checks defined in standard instead of value checks.
Typical example that was working before this release:
const m1 = new Map([[{ a: 1 }, 11]]);
const m2 = new Map([[{ a: 1 }, 11]]);
m1.should.be.eql(m2)
And not this example is breaking. At first view it is a bit unclear why it should not be so. Consider another example:
const m1 = new Map([[{}, 11], [{}, 12]]);
const m2 = new Map([[{}, 11], [{}, 12]]);
m1.should.be.eql(m2)
This example is not that clear if it should assert or not, right? (it should).
As Map and Set (as their weak equavalents) allows to use any type value/ref as key, perfectly equal by value (what should.js do) {} and {} is not equal by reference. In should.js i am always trying to limit users to do not shoot themselfs in their foots and just do right thing if possible and when possible. That is why both examples will throw assertions starting 12.0.0.
Consistency in bundles
For the long time (probably several years now) browser bundle and node bundle has little differences in globals.
To make them sync i am doing such changes to bundles:
- Browser bundle will not contain
window.Should
any more (with capital S). It was deprecated for the long time. Just usewindow.should
as is. - Node bundle change
global.should
to be should function instead of getter attached toObject.prototype
.