Closed
Description
-
Version:
v9.4.0 -
Platform:
OSX, Linux, Windows -
Subsystem:
N/A
util.isDeepStrictEqual always returns true when WeakMap/WeakSet comparison.
const util = require('util');
const wm1 = new WeakMap();
const wm2 = new WeakMap();
const key = {};
wm1.set(key, 1);
wm2.set(key, 2);
console.log(util.isDeepStrictEqual(wm1, wm2)); // true
this is because WeakMap|WeakSet.prototype.valueOf always returns empty object.
I know WeakMap / WeakSet do not have an API to show the full content, and they depends on GC so those collection comparison is very difficult.
However, this behavior (always return true) seems to be curious for me. I think it would be better to always return false.