diff --git a/src/index.js b/src/index.js index 091b453..be72c78 100644 --- a/src/index.js +++ b/src/index.js @@ -60,6 +60,15 @@ const deepCompare = (a, b) => { assert(typeof_a === 'object'); + if (_a === null) { + if (_b === null) continue; + return -1; + } + + if (_b === null) { + return 1; + } + if (pendingOrChecked.has([_a, _b])) continue; pendingOrChecked.add([_a, _b]); pendingOrChecked.add([_b, _a]); diff --git a/test/src/deepCompare.js b/test/src/deepCompare.js index 5d84d54..f15f451 100644 --- a/test/src/deepCompare.js +++ b/test/src/deepCompare.js @@ -68,6 +68,7 @@ test(macro, null, undefined, -1); test(macro, undefined, null, 1); test(macro, undefined, {}, 1); test(macro, {}, undefined, -1); +test(macro, null, {}, -1); test(macro, {}, {}, 0); test(macro, {}, {a: 1}, -1); test(macro, {a: 1}, {}, 1);