benjamn / benjamn/immutable-tuple
-0 is not normalized
Open
- Dominant language
- JavaScript
- Stars
- 38
- Forks
- 3
- PR merge metrics
- No merged PRs in 30d
Description
In JavaScript `Map` and `Set` do not distinguish `0` and `-0` as different keys, instead `-0` is normalized to `0`.
This leads to the following 'bug':
```js
const { tuple } = require("immutable-tuple");
if (Math.random() > 0.5) {
tuple(Object, -0); // sometimes create this first
} else {
tuple(Object, 0); // other times create this first
}
function isNegativeZero(n) {
return Object.is(n, -0);
}
console.log(isNegativeZero(tuple(Object, -0)[1])); // sometimes 'true', sometimes 'false'
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.