From e4fb8c6459aa13d3a110b45e5612c31890a5d94e Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 20 Dec 2019 11:41:32 -0800 Subject: [PATCH 01/18] [Deps] update `is-date-object`, `is-regex`, `object-is`, `regexp.prototype.flags` --- package.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 88fae20..2fc7ced 100644 --- a/package.json +++ b/package.json @@ -20,11 +20,11 @@ }, "dependencies": { "is-arguments": "^1.0.4", - "is-date-object": "^1.0.1", - "is-regex": "^1.0.4", - "object-is": "^1.0.1", + "is-date-object": "^1.0.2", + "is-regex": "^1.0.5", + "object-is": "^1.0.2", "object-keys": "^1.1.1", - "regexp.prototype.flags": "^1.2.0" + "regexp.prototype.flags": "^1.3.0" }, "devDependencies": { "@ljharb/eslint-config": "^15.0.1", From 0f8ca7575e44c66fdf1dc2b6ad4e69e1b549369f Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 20 Dec 2019 11:41:45 -0800 Subject: [PATCH 02/18] [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `tape` --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 2fc7ced..3ff6cdb 100644 --- a/package.json +++ b/package.json @@ -27,11 +27,11 @@ "regexp.prototype.flags": "^1.3.0" }, "devDependencies": { - "@ljharb/eslint-config": "^15.0.1", + "@ljharb/eslint-config": "^15.1.0", "auto-changelog": "^1.16.2", - "eslint": "^6.6.0", + "eslint": "^6.7.2", "safe-publish-latest": "^1.1.4", - "tape": "^4.11.0" + "tape": "^4.12.0" }, "repository": { "type": "git", From f0d4a42fb87854e17d78cb2d6e9ec0156ea3d2f3 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sat, 30 Nov 2019 13:34:10 -0800 Subject: [PATCH 03/18] [Tests] use `Buffer.from` when available --- test/cmp.js | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/test/cmp.js b/test/cmp.js index b377743..77a05c2 100644 --- a/test/cmp.js +++ b/test/cmp.js @@ -94,21 +94,27 @@ test('dates', function (t) { t.end(); }); -test('buffers', function (t) { - /* eslint no-buffer-constructor: 1, new-cap: 1 */ - t.ok(equal(Buffer('xyz'), Buffer('xyz')), 'buffers with same contents are equal'); - t.ok(equal(Buffer('xyz'), Buffer('xyz'), { strict: true }), 'strict: buffers with same contents are equal'); +test('buffers', { skip: typeof Buffer !== 'function' }, function (t) { + var safeBuffer = Buffer.from || Buffer; + t.deepEqualTest( + safeBuffer('xyz'), + safeBuffer('xyz'), + 'buffers with same contents are equal', + true, + true, + true + ); t.deepEqualTest( - Buffer('abc'), - Buffer('xyz'), + safeBuffer('abc'), + safeBuffer('xyz'), 'buffers with different contents', false, false ); t.deepEqualTest( - Buffer(''), + safeBuffer(''), [], 'empty buffer and empty array', false, From f7e577622d943da78c2c9cd1e070eb786cf7a68b Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 1 Dec 2019 00:13:16 -0800 Subject: [PATCH 04/18] [Tests] only use `Buffer.from` when it has a length of > 1 This avoids tests throwing "not a typed array" in node v5.0-v5.9 + v4.0-v4.4 --- test/cmp.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/cmp.js b/test/cmp.js index 77a05c2..ab24bee 100644 --- a/test/cmp.js +++ b/test/cmp.js @@ -95,7 +95,7 @@ test('dates', function (t) { }); test('buffers', { skip: typeof Buffer !== 'function' }, function (t) { - var safeBuffer = Buffer.from || Buffer; + var safeBuffer = Buffer.from && Buffer.from.length > 1 ? Buffer.from : Buffer; t.deepEqualTest( safeBuffer('xyz'), safeBuffer('xyz'), From 11bd45b63943466c13a5ae97276796396a8f2619 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 20 Oct 2023 13:27:17 -0700 Subject: [PATCH 05/18] [Dev Deps] update `@ljharb/eslint-config`, `auto-changelog`, `aud`, `eslint`, `set-publish-latest`, `tape` --- CHANGELOG.md | 186 +++++++++++++++++++++++++++++++++++++++++++++++++-- package.json | 17 +++-- 2 files changed, 192 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0bf6ad8..a7394f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,185 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). +## [v2.2.2](https://github.com/inspect-js/node-deep-equal/compare/v2.2.1...v2.2.2) - 2023-07-10 + +### Commits + +- [Fix] avoid an infinite loop in node 0.8 with Typed Arrays [`f247282`](https://github.com/inspect-js/node-deep-equal/commit/f247282e66060087c51221f77b9170fa0e2e461b) +- [Dev Deps] update `@ljharb/eslint-config`, `aud`, `tape` [`fa25583`](https://github.com/inspect-js/node-deep-equal/commit/fa255839c1afed228c41ca76177a8c239ec9305a) +- [Deps] update `get-intrinsic` [`3638470`](https://github.com/inspect-js/node-deep-equal/commit/3638470e71ed6185e06a0f0694e77cbf4c2b791c) + +## [v2.2.1](https://github.com/inspect-js/node-deep-equal/compare/v2.2.0...v2.2.1) - 2023-04-27 + +### Commits + +- [Tests] add passing tests covering object key ordering [`51c9ff6`](https://github.com/inspect-js/node-deep-equal/commit/51c9ff6b4c5d4371e0f444ce1160e416bf88e21f) +- [Refactor] use `array-buffer-byte-length` [`f47822c`](https://github.com/inspect-js/node-deep-equal/commit/f47822cf0c188caa71dfbb107b081324fcb6b99d) +- [Deps] update `is-array-buffer`, `regexp.prototype.flags` [`160d851`](https://github.com/inspect-js/node-deep-equal/commit/160d8513335d63256f9826835b35d1a462c76771) +- [Deps] update `es-get-iterator`, `get-intrinsic` [`2e08e95`](https://github.com/inspect-js/node-deep-equal/commit/2e08e956a43c839246d2280cfaaa3f3200937bbd) +- [Dev Deps] update `object.getownpropertydescriptors` [`63e9ab7`](https://github.com/inspect-js/node-deep-equal/commit/63e9ab7450212bf7e393c1bf725293389cb4626a) +- [Dev Deps] update `tape` [`c8db964`](https://github.com/inspect-js/node-deep-equal/commit/c8db964f605834388b0df20c5fce49cfbaa541bc) + +## [v2.2.0](https://github.com/inspect-js/node-deep-equal/compare/v2.1.0...v2.2.0) - 2023-01-05 + +### Commits + +- [New] add support for `SharedArrayBuffer` [`0ef51c7`](https://github.com/inspect-js/node-deep-equal/commit/0ef51c79b7dcd6ae5890b2dce4304be7c8ebe314) +- [Refactor] use `is-array-buffer` package [`0360ee1`](https://github.com/inspect-js/node-deep-equal/commit/0360ee1f1bb6e5804c15a9a4aa75ff84120a33e1) +- [Fix] `whichTypedArray` can return false in both cases [`df3e3c4`](https://github.com/inspect-js/node-deep-equal/commit/df3e3c4e30552b7a7892b62dc45fccd31eac9bfe) +- [Dev Deps] update `aud`, `object.getownpropertydescriptors` [`6d62ea4`](https://github.com/inspect-js/node-deep-equal/commit/6d62ea4f2b82d4f861fd3e0c2d67916939b1edbc) +- [Dev Deps] update `@ljharb/eslint-config` [`15aab59`](https://github.com/inspect-js/node-deep-equal/commit/15aab59d647628e05b77d1897036d73884f7a107) +- [Deps] update `which-typed-array` [`8dfce27`](https://github.com/inspect-js/node-deep-equal/commit/8dfce27f333721c697b90569b26e4bded0d61d88) +- [eslint] remove `.eslintignore` [`af46773`](https://github.com/inspect-js/node-deep-equal/commit/af46773b281dc67d7743280505a22248f0f0748d) + +## [v2.1.0](https://github.com/inspect-js/node-deep-equal/compare/v2.0.5...v2.1.0) - 2022-11-02 + +### Fixed + +- [New] add support for `ArrayBuffer` [`#94`](https://github.com/inspect-js/node-deep-equal/issues/94) + +### Commits + +- [actions] reuse common workflows [`12de287`](https://github.com/inspect-js/node-deep-equal/commit/12de2873def84c621421b1e3d4a96babf2ceb30a) +- [actions] use `node/install` instead of `node/run`; use `codecov` action [`ec248b9`](https://github.com/inspect-js/node-deep-equal/commit/ec248b96f4f91eb4c5971dfec74d6d91f04b39cd) +- [Tests] run assert tests on a dynamic matrix [`695aebd`](https://github.com/inspect-js/node-deep-equal/commit/695aebd50945621984bfa7e60b5c99f79dbacf1a) +- [readme] add badges [`492e159`](https://github.com/inspect-js/node-deep-equal/commit/492e1591585233184151b5526cf5413e61a2aa89) +- [Test] ArrayBuffers in node < 0.12 have a nonconfigurable own `byteLength` property [`40f4b87`](https://github.com/inspect-js/node-deep-equal/commit/40f4b8719658f6262399b24791d4ccb5960ca8ea) +- [meta] use `npmignore` to autogenerate an npmignore file [`2627269`](https://github.com/inspect-js/node-deep-equal/commit/26272693147d68ec3ae2216b1f3ac5d30b79b3da) +- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `safe-publish-latest`, `tape` [`7a05bb7`](https://github.com/inspect-js/node-deep-equal/commit/7a05bb7482817616243fc89956abf48710d77fea) +- [Deps] update `call-bind`, `es-get-iterator`, `get-intrinsic`, `is-arguments`, `is-regex`, `regexp.prototype.flags`, `side-channel`, `which-boxed-primitive`, `which-typed-array` [`c0844e6`](https://github.com/inspect-js/node-deep-equal/commit/c0844e629ba3dc5193fd41a75ebcedaba976c1af) +- [actions] update codecov uploader [`b1b0552`](https://github.com/inspect-js/node-deep-equal/commit/b1b0552fe3dc23029a2717f84642e53548902e68) +- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `auto-changelog`, `has-symbols`, `object.getownpropertydescriptors`, `tape` [`9a1ccf5`](https://github.com/inspect-js/node-deep-equal/commit/9a1ccf5285317962fe37baa211c2b20081be71ef) +- [meta] do not publish github action workflow files [`2d63384`](https://github.com/inspect-js/node-deep-equal/commit/2d63384d6676b593c2a74b45747ac81cea3da76e) +- [actions] update rebase action to use reusable workflow [`69d21f5`](https://github.com/inspect-js/node-deep-equal/commit/69d21f55af0bcff1c41447a6ac396ae556fda226) +- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `has-symbols`, `object.getownpropertydescriptors`, `tape` [`297aae8`](https://github.com/inspect-js/node-deep-equal/commit/297aae88f619b1e058418be32e37fc29770b4f21) +- [Tests] add tests for regexes with the same source but different flags [`29c8a0d`](https://github.com/inspect-js/node-deep-equal/commit/29c8a0da09567b3bbe6614c1e235d5a87d7bdaf2) +- [Dev Deps] update `eslint`, `@ljharb/eslint-config` [`9e64ec9`](https://github.com/inspect-js/node-deep-equal/commit/9e64ec93a8c5cbe87315d30dd62a8fe6dcf842b4) +- [Deps] update `is-arguments`, `is-date-object`, `is-regex`, `which-typed-array` [`edfb752`](https://github.com/inspect-js/node-deep-equal/commit/edfb752810699790c06bb424174f38b449a4b8fb) +- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `auto-changelog`, `tape` [`7b5f7a3`](https://github.com/inspect-js/node-deep-equal/commit/7b5f7a348b2bb78ca1c00003d0dd3444d5a372a6) +- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `has-typed-arrays`, `tape` [`e328a23`](https://github.com/inspect-js/node-deep-equal/commit/e328a237ba9c262d8c2d178a65d5e1f744cbbd6b) +- [Deps] update `get-intrinsic`, `regexp.prototype.flags`, `which-typed-array` [`29123a7`](https://github.com/inspect-js/node-deep-equal/commit/29123a71857c27cce497ac991fa9be0e5921adce) +- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud` [`b7039ef`](https://github.com/inspect-js/node-deep-equal/commit/b7039effc1b751cb579095f9738ee019d8458a41) +- [Dev Deps] update `aud`, `tape` [`9d0b2e0`](https://github.com/inspect-js/node-deep-equal/commit/9d0b2e07df24dfd1d4d9bf32cdca07e6e1377f23) +- [actions] update workflows [`a5f5a7e`](https://github.com/inspect-js/node-deep-equal/commit/a5f5a7ed570e35cefad08ed32652cb8647d0166c) +- [Deps] update `get-intrinsic`, `object.assign` [`02025e2`](https://github.com/inspect-js/node-deep-equal/commit/02025e21dfbce6a4d52421c4892ba743dd7a7540) +- [Test] node < 4 lacks `ArrayBuffer.prototype.fill` [`bb65b07`](https://github.com/inspect-js/node-deep-equal/commit/bb65b07d39eeea03ca066a92892a06a607641ed7) +- [Deps] update `is-date-object`, `is-regex` [`a463ed2`](https://github.com/inspect-js/node-deep-equal/commit/a463ed26ba7ca4b818db4929e4e946ddc0590bce) +- [Deps] update `get-intrinsic`, `object-is` [`2a33cce`](https://github.com/inspect-js/node-deep-equal/commit/2a33cced17827df191676ecdd9b9bc4f0d814aa6) +- [actions] update workflows [`d905278`](https://github.com/inspect-js/node-deep-equal/commit/d90527855a35bcaeef70d3e21370580d7d182c8d) +- [meta] use `prepublishOnly` script for npm 7+ [`7b66184`](https://github.com/inspect-js/node-deep-equal/commit/7b661846aedb0ad5768f1118e93c662d214c85f8) +- [Dev Deps] update `object.getownpropertydescriptors` [`d970dbc`](https://github.com/inspect-js/node-deep-equal/commit/d970dbcf4a95c58d5bbd6ea507455bbfa1e7ec02) + +## [v2.0.5](https://github.com/inspect-js/node-deep-equal/compare/v2.0.4...v2.0.5) - 2020-12-01 + +### Commits + +- [Tests] migrate tests to Github Actions [`4051a18`](https://github.com/inspect-js/node-deep-equal/commit/4051a1811612fd1b107743a092402361f597f89a) +- [meta] add Automatic Rebase and Require Allow Edits workflows [`6682b15`](https://github.com/inspect-js/node-deep-equal/commit/6682b15417630d6c57c854d088dfcd6023b3e185) +- [Deps] use `call-bind` and `get-intrinsic` instead of `es-abstract`; update `es-get-iterator`, `object-is`, `object.assign` [`a1d6d93`](https://github.com/inspect-js/node-deep-equal/commit/a1d6d931ebc80db8a6dba1bd453165356458f9e1) +- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `object.getownpropertydescriptors` [`b142f4b`](https://github.com/inspect-js/node-deep-equal/commit/b142f4b9458c320b944dc06f57b9339530cf404e) + +## [v2.0.4](https://github.com/inspect-js/node-deep-equal/compare/v2.0.3...v2.0.4) - 2020-10-01 + +### Fixed + +- [meta] fix incorrect `./package.json` exports entry [`#89`](https://github.com/inspect-js/node-deep-equal/issues/89) + +### Commits + +- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `auto-changelog` [`d6bfee3`](https://github.com/inspect-js/node-deep-equal/commit/d6bfee329e2a430a12e6a4aba7006c5d7c36020e) +- [Tests] account for node 14+ making two NaNs loosely deep equal [`9367954`](https://github.com/inspect-js/node-deep-equal/commit/93679546d97dbd92d615b0f758d733ea1fb4eb4b) +- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `tape` [`86a159b`](https://github.com/inspect-js/node-deep-equal/commit/86a159b72c3e3620285498113251220d3c5d05f0) +- [Deps] update `es-abstract`, `object-is`, `object.assign` [`e87979d`](https://github.com/inspect-js/node-deep-equal/commit/e87979d311faa537622a6c9faee6e91cf9a08bcd) +- [Deps] update `es-abstract`, `is-regex` [`d0cacca`](https://github.com/inspect-js/node-deep-equal/commit/d0cacca140b963d8abbe10f6bf640f22ef11f7b0) +- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `tape` [`375a9e1`](https://github.com/inspect-js/node-deep-equal/commit/375a9e1e4911b3210e328365432c8cf946d0a7e2) +- [Dev Deps] update `eslint`, `auto-changelog` [`e562d4f`](https://github.com/inspect-js/node-deep-equal/commit/e562d4fadebf09b1fca02d6f43e1c933c6ef8242) +- [Deps] update `side-channel` [`f092342`](https://github.com/inspect-js/node-deep-equal/commit/f092342373d4a33b3f679042f357fd800185caad) + +## [v2.0.3](https://github.com/inspect-js/node-deep-equal/compare/v2.0.2...v2.0.3) - 2020-04-23 + +### Commits + +- [Deps] update `object-is`, `which-typed-array` [`c232374`](https://github.com/inspect-js/node-deep-equal/commit/c2323741001f7cb2414f4fa26301f1b9705e6b46) +- [Dev Deps] update `auto-changelog`; add `aud` [`c80a91d`](https://github.com/inspect-js/node-deep-equal/commit/c80a91d8b9815300fc9e24f08094cac8942d9da7) +- [Dev Deps] update `auto-changelog` [`295d195`](https://github.com/inspect-js/node-deep-equal/commit/295d19529365a87ed663eecf26f19effe5b06f3c) +- [Dev Deps] update `aud` [`1134cc2`](https://github.com/inspect-js/node-deep-equal/commit/1134cc26fd112e3679a6973f4d418c4495e3358d) +- [Deps] Fix classification of `object.assign` [`32695dd`](https://github.com/inspect-js/node-deep-equal/commit/32695dd88c3eb86c87e162830e0e1c55447a4b9f) + +## [v2.0.2](https://github.com/inspect-js/node-deep-equal/compare/v2.0.1...v2.0.2) - 2020-04-01 + +### Commits + +- [Fix] properly pass `strict` option through internals [`4e2919d`](https://github.com/inspect-js/node-deep-equal/commit/4e2919d7c403413a9cf094b2f3be095653670e97) +- [Tests] add more coverage [`a3d8677`](https://github.com/inspect-js/node-deep-equal/commit/a3d86774fa39e1a00b3371a32fbe42c7b38743ff) +- [Tests] add coverage reporting [`3174e33`](https://github.com/inspect-js/node-deep-equal/commit/3174e33f952a4bdd57c43e3b40dea705d3d61e68) +- [Refactor] add strict pragma; remove unused try/catch [`c1d173e`](https://github.com/inspect-js/node-deep-equal/commit/c1d173ebadfcc4a2574f28b17727239dcd2737be) +- [Fix] the `prototype` property is not special on non-functions [`1c3cc25`](https://github.com/inspect-js/node-deep-equal/commit/1c3cc2526766e52cc32b9c1859b7073d5dbb70aa) +- [Deps] update `es-abstract`, `es-get-iterator`, `is-date-object`, `is-regex`, `object-is`, `regexp.prototype.flags`, `side-channel` [`7787bdc`](https://github.com/inspect-js/node-deep-equal/commit/7787bdc1268620ef12d17777fce3682abc4e364e) +- [Deps] update `es-abstract`, `es-get-iterator`, `which-collection` [`87624cf`](https://github.com/inspect-js/node-deep-equal/commit/87624cf96f2ca00bf5200aa860c4574dba96f4aa) +- [Fix] robustly distinguish Typed Arrays [`7ccb2b0`](https://github.com/inspect-js/node-deep-equal/commit/7ccb2b0f88136516cd58cad74d9c0a20daad824c) +- [Dev Deps] update `@ljharb/eslint-config`, `tape` [`c1814a1`](https://github.com/inspect-js/node-deep-equal/commit/c1814a1256e373ac6e7953b354f9f56ff5b7fe89) +- [Dev Deps] update `@ljharb/eslint-config`, `object.getownpropertydescriptors`, `tape` [`7a0d819`](https://github.com/inspect-js/node-deep-equal/commit/7a0d819e5b3807eab873d7961eb34e30ff615943) +- [Dev Deps] update `auto-changelog`, `tape` [`f248756`](https://github.com/inspect-js/node-deep-equal/commit/f2487567b092d90005a7d09b084f7ffb9ba71257) +- [Tests] fix `tag` helper, from bb50ea2e6d7906cd58683fdc7d327660e71612f4 [`469f008`](https://github.com/inspect-js/node-deep-equal/commit/469f0089d16d8678ee4c5f57016d40f072b3f7be) +- [Dev Deps] update `eslint`, `tape` [`6537dce`](https://github.com/inspect-js/node-deep-equal/commit/6537dcef16c792546c3a40ea5b53ab43861cf719) +- [Fix] make `isBuffer` check slightly more robust [`c21e14d`](https://github.com/inspect-js/node-deep-equal/commit/c21e14d7afe7d53391fa95fd8c59f85affc02ac6) +- [meta] disable greenkeeper updates for semver [`724f051`](https://github.com/inspect-js/node-deep-equal/commit/724f051213e159d5a021d0649e6a2cafd4c13458) +- [Deps] update `es-abstract` [`942ad86`](https://github.com/inspect-js/node-deep-equal/commit/942ad8699442dd83207bb04ae079997b3433ca60) +- [Deps] update `es-abstract` [`8724052`](https://github.com/inspect-js/node-deep-equal/commit/8724052e10d2e897626af6f46e0bce9d35523b04) + +## [v2.0.1](https://github.com/inspect-js/node-deep-equal/compare/v2.0.0...v2.0.1) - 2019-12-08 + +### Fixed + +- [Fix] `Map` and `Set` comparison: keys are loosely compared also [`#75`](https://github.com/inspect-js/node-deep-equal/issues/75) + +### Commits + +- [Fix] check extra properties on regexps [`1eac46b`](https://github.com/inspect-js/node-deep-equal/commit/1eac46b69c7b499cecb7e3b555b6e260de2043fd) +- [Tests] update test skipping logic [`8adf08d`](https://github.com/inspect-js/node-deep-equal/commit/8adf08dcb91146590f2c57b614de6a853054f297) + +## [v2.0.0](https://github.com/inspect-js/node-deep-equal/compare/v1.1.1...v2.0.0) - 2019-12-03 + +### Fixed + +- [Fix] handle circular references [`#19`](https://github.com/inspect-js/node-deep-equal/issues/19) +- [Breaking] compare `Map`, `Set`, `WeakMap`, `WeakSet` matching node assert [`#54`](https://github.com/inspect-js/node-deep-equal/issues/54) [`#46`](https://github.com/inspect-js/node-deep-equal/issues/46) +- [Breaking] compare `Map`, `Set`, `WeakMap`, `WeakSet` matching node assert [`#54`](https://github.com/inspect-js/node-deep-equal/issues/54) [`#46`](https://github.com/inspect-js/node-deep-equal/issues/46) +- [Breaking] comparing arrays and objects should always fail, per node‘s assert.deepEqual [`#12`](https://github.com/inspect-js/node-deep-equal/issues/12) + +### Commits + +- [Tests] add passing tests from node core [`91a6472`](https://github.com/inspect-js/node-deep-equal/commit/91a6472719331eca1b13472db798e7f3188af9f7) +- [Tests] convert remaining tests to use the custom assertion [`2bb7269`](https://github.com/inspect-js/node-deep-equal/commit/2bb7269013574a9a4e84ec5e34a04258f3ecd94a) +- [Tests] add tests for getters, fake arrays, overriding getTime on Dates [`1b66d90`](https://github.com/inspect-js/node-deep-equal/commit/1b66d90232a5a576d0334f0c109f8c79da487c9f) +- [Breaking] non-Date objects with different [[Prototypes]] are not equal [`5f2f2e5`](https://github.com/inspect-js/node-deep-equal/commit/5f2f2e55a3cfea251ca502a7846489a9133b4347) +- [Breaking] boxed primitives are not silently unboxed [`e207bc3`](https://github.com/inspect-js/node-deep-equal/commit/e207bc352f338a5c57b2ef2ce59d78b821fb2b58) +- [Tests] run tests with assert, as well [`ccaf3ea`](https://github.com/inspect-js/node-deep-equal/commit/ccaf3eabb081d255f9fafcf2cc2631eafaa9b2a7) +- [Breaking] boxed primitives are unwrapped for comparisons [`a159a3a`](https://github.com/inspect-js/node-deep-equal/commit/a159a3a0660a2da9a8ff6392aba4b2de81bc8391) +- [Refactor] use `side-channel` for memoizing circular refs [`983780a`](https://github.com/inspect-js/node-deep-equal/commit/983780aec338b8d909c3f6a5b1e0f4d7fe1d78b5) +- [Tests] Failing tests for Map equality [`4856185`](https://github.com/inspect-js/node-deep-equal/commit/4856185d989914e2f440fe3fd3bac4d977365fe2) +- [Tests] add `toStringTag` helper [`bb50ea2`](https://github.com/inspect-js/node-deep-equal/commit/bb50ea2e6d7906cd58683fdc7d327660e71612f4) +- [Fix] robustly unbox boxed primitives, using `unbox-primitive` [`c455998`](https://github.com/inspect-js/node-deep-equal/commit/c45599893f02f349604a7b39b39f45036ea2e499) +- [Breaking] two objects with different `Symbol.toStringTag`s are not equal [`45431b6`](https://github.com/inspect-js/node-deep-equal/commit/45431b67b5e7e9cb91d5ff8706dc55348d59184e) +- [Tests] add more Error tests [`c0ae38c`](https://github.com/inspect-js/node-deep-equal/commit/c0ae38c43872621da83aba608cd62b951de7c4c6) +- [Breaking] ensure `Error` objects compare properly [`ffb2522`](https://github.com/inspect-js/node-deep-equal/commit/ffb2522eb94afe46a8ccc23faebdcee23ea6f170) +- [Dev Deps] update `eslint`, `@ljharb/eslint-config` [`737031e`](https://github.com/inspect-js/node-deep-equal/commit/737031e9ac09812ec7181040e857d8b73b573970) +- [readme] update URLs, readme [`9d300da`](https://github.com/inspect-js/node-deep-equal/commit/9d300da78ce21dcca7259bb557765cfac0db3e16) +- [Tests] use `Buffer.from` when available [`43fa5da`](https://github.com/inspect-js/node-deep-equal/commit/43fa5dafe17b1287f56c2566c487a9c05946fe4f) +- [Breaking] add `exports` to `package.json` [`ecd15ae`](https://github.com/inspect-js/node-deep-equal/commit/ecd15aedeeddc8f386ed8b54296648ee4a73af9b) +- [Tests] require ASSERT tests to pass [`7ac77cf`](https://github.com/inspect-js/node-deep-equal/commit/7ac77cf21081b30eeadb5ac5201b30ad0d4dcbe4) +- [Robustness] use `callBound` from `es-abstract` [`4dc3477`](https://github.com/inspect-js/node-deep-equal/commit/4dc347792be1f7131b3095ba98590a599cce7e20) +- [patch] [[Prototype]]s are only compared in strict mode [`43b1eef`](https://github.com/inspect-js/node-deep-equal/commit/43b1eef2eb7bc3045fb160bf5d755bce44cbfd52) +- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `has-symbols` [`89228df`](https://github.com/inspect-js/node-deep-equal/commit/89228df447b174008e163f1c83c8f0f559e30fa0) +- [Tests] up to `node` `v12.9` [`595c81a`](https://github.com/inspect-js/node-deep-equal/commit/595c81a2e2c1baab216b2dac640ed020f49033bf) +- [Fix] pass options when comparing Collection keys/values [`9859584`](https://github.com/inspect-js/node-deep-equal/commit/9859584ae2f4f46ec602e18bac9610c71ff00e2f) +- [Breaking] `false` and `[]` are no longer equal, even non-strictly [`5c3accc`](https://github.com/inspect-js/node-deep-equal/commit/5c3acccf541ba0b77342c2a441b32a43acebc73e) +- [Tests] only use `Buffer.from` when it has a length of > 1 [`3645129`](https://github.com/inspect-js/node-deep-equal/commit/3645129d7692c5195ae4b94ba83d2fe84d9538d7) +- [Breaking] remove `lib/is-arguments` and `lib/keys` entrypoints [`783d47e`](https://github.com/inspect-js/node-deep-equal/commit/783d47e3092b7a62aaecbf6836b18a0dfca96662) +- [Dev Deps] update `eslint` [`7cc1dd9`](https://github.com/inspect-js/node-deep-equal/commit/7cc1dd986fc30946ca06ba6496ef856cfb911cf3) +- Merge tag 'v1.1.1' [`f9d3c6d`](https://github.com/inspect-js/node-deep-equal/commit/f9d3c6d1e4a895c448ba7d8766f8616d0e235c9a) +- Merge tag 'v1.1.0' [`0aeca99`](https://github.com/inspect-js/node-deep-equal/commit/0aeca9988dba6fe3318f46c47c933e6926175278) ## [v1.1.1](https://github.com/inspect-js/node-deep-equal/compare/v1.1.0...v1.1.1) - 2019-11-12 @@ -17,7 +195,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). - [Tests] add `npx aud` in `posttest` [`0b76639`](https://github.com/inspect-js/node-deep-equal/commit/0b766394504f74d002ad85e7b8244ce89bb27130) - [meta] add `funding` field [`3e519e3`](https://github.com/inspect-js/node-deep-equal/commit/3e519e36998ea82120cfe9a509dc0090a87d7063) -## [v1.1.0](https://github.com/inspect-js/node-deep-equal/compare/v1.0.1...v1.1.0) - 2019-08-28 +## [v1.1.0](https://github.com/inspect-js/node-deep-equal/compare/v1.0.1...v1.1.0) - 2019-08-27 ### Commits @@ -75,7 +253,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). - buffer check without Buffer [`5271f39`](https://github.com/inspect-js/node-deep-equal/commit/5271f39f3ce61fecb71fa6ca28cb4a8a8b963bbd) - failing test for buffer comparison [`cc8990b`](https://github.com/inspect-js/node-deep-equal/commit/cc8990b9d84a2267d84253e21c9f7db238e961e9) -## [v0.1.2](https://github.com/inspect-js/node-deep-equal/compare/v0.1.1...v0.1.2) - 2013-12-21 +## [v0.1.2](https://github.com/inspect-js/node-deep-equal/compare/v0.1.1...v0.1.2) - 2013-12-20 ### Commits @@ -110,7 +288,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). - performance note in the readme [`da9bfc9`](https://github.com/inspect-js/node-deep-equal/commit/da9bfc9aadfb9045bbf8157e9403de7184b404fd) - more firefoxes [`3d60ec5`](https://github.com/inspect-js/node-deep-equal/commit/3d60ec58d6fe269c13c5be04b749f01972aa5b1c) -## v0.0.0 - 2012-02-11 +## v0.0.0 - 2012-02-10 ### Commits diff --git a/package.json b/package.json index 3ff6cdb..e6da45f 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,8 @@ "test": "test" }, "scripts": { - "prepublish": "safe-publish-latest", + "prepublishOnly": "safe-publish-latest", + "prepublish": "not-in-publish || npm run prepublishOnly", "pretest": "npm run lint", "lint": "eslint .", "tests-only": "tape test/*", @@ -27,11 +28,12 @@ "regexp.prototype.flags": "^1.3.0" }, "devDependencies": { - "@ljharb/eslint-config": "^15.1.0", - "auto-changelog": "^1.16.2", - "eslint": "^6.7.2", - "safe-publish-latest": "^1.1.4", - "tape": "^4.12.0" + "@ljharb/eslint-config": "^21.1.0", + "auto-changelog": "^2.4.0", + "eslint": "=8.8.0", + "in-publish": "^2.0.1", + "safe-publish-latest": "^2.0.0", + "tape": "^5.7.1" }, "repository": { "type": "git", @@ -82,6 +84,7 @@ "template": "keepachangelog", "unreleased": false, "commitLimit": false, - "backfillLimit": false + "backfillLimit": false, + "hideCredit": true } } From b0bca9a1158a9596ec51a0404a6a8272b70ee204 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 20 Oct 2023 13:28:36 -0700 Subject: [PATCH 06/18] [readme] update readme from default branch --- readme.markdown | 40 ++++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/readme.markdown b/readme.markdown index e8976f4..6fbb643 100644 --- a/readme.markdown +++ b/readme.markdown @@ -1,13 +1,15 @@ -# deep-equal +# deep-equal [![Version Badge][npm-version-svg]][package-url] -Node's `assert.deepEqual() algorithm` as a standalone module. +Node's `assert.deepEqual() algorithm` as a standalone module, that also works in browser environments. -This module is around [5 times faster](https://gist.github.com/2790507) -than wrapping `assert.deepEqual()` in a `try/catch`. +It mirrors the robustness of node's own `assert.deepEqual` and is robust against later builtin modification. -[![browser support](https://ci.testling.com/substack/node-deep-equal.png)](https://ci.testling.com/substack/node-deep-equal) +[![github actions][actions-image]][actions-url] +[![coverage][codecov-image]][codecov-url] +[![License][license-image]][license-url] +[![Downloads][downloads-image]][downloads-url] -[![build status](https://secure.travis-ci.org/substack/node-deep-equal.png)](https://travis-ci.org/substack/node-deep-equal) +[![npm badge][npm-badge-png]][package-url] # example @@ -33,16 +35,14 @@ var deepEqual = require('deep-equal') ## deepEqual(a, b, opts) -Compare objects `a` and `b`, returning whether they are equal according to a -recursive equality algorithm. +Compare objects `a` and `b`, returning whether they are equal according to a recursive equality algorithm. If `opts.strict` is `true`, use strict equality (`===`) to compare leaf nodes. -The default is to use coercive equality (`==`) because that's how -`assert.deepEqual()` works by default. +The default is to use coercive equality (`==`) because that's how `assert.deepEqual()` works by default. # install -With [npm](http://npmjs.org) do: +With [npm](https://npmjs.org) do: ``` npm install deep-equal @@ -50,8 +50,24 @@ npm install deep-equal # test -With [npm](http://npmjs.org) do: +With [npm](https://npmjs.org) do: ``` npm test ``` + +[package-url]: https://npmjs.org/package/deep-equal +[npm-version-svg]: https://versionbadg.es/inspect-js/deep-equal.svg +[deps-svg]: https://david-dm.org/inspect-js/node-deep-equal.svg +[deps-url]: https://david-dm.org/inspect-js/node-deep-equal +[dev-deps-svg]: https://david-dm.org/inspect-js/node-deep-equal/dev-status.svg +[dev-deps-url]: https://david-dm.org/inspect-js/node-deep-equal#info=devDependencies +[npm-badge-png]: https://nodei.co/npm/deep-equal.png?downloads=true&stars=true +[license-image]: https://img.shields.io/npm/l/deep-equal.svg +[license-url]: LICENSE +[downloads-image]: https://img.shields.io/npm/dm/deep-equal.svg +[downloads-url]: https://npm-stat.com/charts.html?package=deep-equal +[codecov-image]: https://codecov.io/gh/inspect-js/node-deep-equal/branch/main/graphs/badge.svg +[codecov-url]: https://app.codecov.io/gh/inspect-js/node-deep-equal/ +[actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/inspect-js/node-deep-equal +[actions-url]: https://github.com/inspect-js/node-deep-equal/actions From 80c15cae82164c888de8635287c3b44ab84b3fd4 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 20 Oct 2023 13:29:02 -0700 Subject: [PATCH 07/18] [Deps] update `is-arguments`, `is-date-object`, `is-regex`, `object-is`, `regexp.prototype.flags` --- package.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index e6da45f..09c3659 100644 --- a/package.json +++ b/package.json @@ -20,12 +20,12 @@ "postversion": "auto-changelog && git add CHANGELOG.md && git commit --no-edit --amend && git tag -f \"v$(node -e \"console.log(require('./package.json').version)\")\"" }, "dependencies": { - "is-arguments": "^1.0.4", - "is-date-object": "^1.0.2", - "is-regex": "^1.0.5", - "object-is": "^1.0.2", + "is-arguments": "^1.1.1", + "is-date-object": "^1.0.5", + "is-regex": "^1.1.4", + "object-is": "^1.1.5", "object-keys": "^1.1.1", - "regexp.prototype.flags": "^1.3.0" + "regexp.prototype.flags": "^1.5.1" }, "devDependencies": { "@ljharb/eslint-config": "^21.1.0", From 58885d3280fd25909ca5a17c7cec1e54bdd25233 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 20 Oct 2023 13:29:42 -0700 Subject: [PATCH 08/18] [Tests] update `.github` from default branch --- .github/workflows/node-assert.yml | 65 +++++++++++++++++++++++ .github/workflows/node-aught.yml | 18 +++++++ .github/workflows/node-pretest.yml | 7 +++ .github/workflows/node-tens.yml | 18 +++++++ .github/workflows/rebase.yml | 9 ++++ .github/workflows/require-allow-edits.yml | 12 +++++ 6 files changed, 129 insertions(+) create mode 100644 .github/workflows/node-assert.yml create mode 100644 .github/workflows/node-aught.yml create mode 100644 .github/workflows/node-pretest.yml create mode 100644 .github/workflows/node-tens.yml create mode 100644 .github/workflows/rebase.yml create mode 100644 .github/workflows/require-allow-edits.yml diff --git a/.github/workflows/node-assert.yml b/.github/workflows/node-assert.yml new file mode 100644 index 0000000..112419d --- /dev/null +++ b/.github/workflows/node-assert.yml @@ -0,0 +1,65 @@ +name: 'Tests: node.js `assert`' + +on: [pull_request, push] + +jobs: + matrix: + runs-on: ubuntu-latest + outputs: + requireds: ${{ steps.set-matrix.outputs.requireds }} + optionals: ${{ steps.set-matrix.outputs.optionals }} + steps: + - uses: ljharb/actions/node/matrix@main + id: set-matrix + with: + type: 'majors' + requireds: '^12.16 || >= 13.4' + optionals: '>= 8 < 12.16 || ^13.0 < 13.4' + + assert-required: + needs: [matrix] + name: 'assert: required' + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: ${{ fromJson(needs.matrix.outputs.requireds) }} + + steps: + - uses: actions/checkout@v2 + - uses: ljharb/actions/node/install@main + name: 'nvm install ${{ matrix.node-version }} && npm install' + with: + node-version: ${{ matrix.node-version }} + - run: npm run tests-only + env: + ASSERT: true + - uses: codecov/codecov-action@v2 + + assert-optional: + needs: [matrix] + name: 'assert: optional' + runs-on: ubuntu-latest + continue-on-error: true + + strategy: + fail-fast: false + matrix: ${{ fromJson(needs.matrix.outputs.optionals) }} + + steps: + - uses: actions/checkout@v2 + - uses: ljharb/actions/node/install@main + name: 'nvm install ${{ matrix.node-version }} && npm install' + with: + node-version: ${{ matrix.node-version }} + - run: npm run tests-only + env: + ASSERT: true + - uses: codecov/codecov-action@v2 + + assert: + name: 'node: assert' + needs: [assert-required, assert-optional] + runs-on: ubuntu-latest + steps: + - run: 'echo tests completed' diff --git a/.github/workflows/node-aught.yml b/.github/workflows/node-aught.yml new file mode 100644 index 0000000..f3cddd8 --- /dev/null +++ b/.github/workflows/node-aught.yml @@ -0,0 +1,18 @@ +name: 'Tests: node.js < 10' + +on: [pull_request, push] + +jobs: + tests: + uses: ljharb/actions/.github/workflows/node.yml@main + with: + range: '< 10' + type: minors + command: npm run tests-only + + node: + name: 'node < 10' + needs: [tests] + runs-on: ubuntu-latest + steps: + - run: 'echo tests completed' diff --git a/.github/workflows/node-pretest.yml b/.github/workflows/node-pretest.yml new file mode 100644 index 0000000..765edf7 --- /dev/null +++ b/.github/workflows/node-pretest.yml @@ -0,0 +1,7 @@ +name: 'Tests: pretest/posttest' + +on: [pull_request, push] + +jobs: + tests: + uses: ljharb/actions/.github/workflows/pretest.yml@main diff --git a/.github/workflows/node-tens.yml b/.github/workflows/node-tens.yml new file mode 100644 index 0000000..b49ceb1 --- /dev/null +++ b/.github/workflows/node-tens.yml @@ -0,0 +1,18 @@ +name: 'Tests: node.js >= 10' + +on: [pull_request, push] + +jobs: + tests: + uses: ljharb/actions/.github/workflows/node.yml@main + with: + range: '>= 10' + type: minors + command: npm run tests-only + + node: + name: 'node >= 10' + needs: [tests] + runs-on: ubuntu-latest + steps: + - run: 'echo tests completed' diff --git a/.github/workflows/rebase.yml b/.github/workflows/rebase.yml new file mode 100644 index 0000000..b9e1712 --- /dev/null +++ b/.github/workflows/rebase.yml @@ -0,0 +1,9 @@ +name: Automatic Rebase + +on: [pull_request_target] + +jobs: + _: + uses: ljharb/actions/.github/workflows/rebase.yml@main + secrets: + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/require-allow-edits.yml b/.github/workflows/require-allow-edits.yml new file mode 100644 index 0000000..7b842f8 --- /dev/null +++ b/.github/workflows/require-allow-edits.yml @@ -0,0 +1,12 @@ +name: Require “Allow Edits” + +on: [pull_request_target] + +jobs: + _: + name: "Require “Allow Edits”" + + runs-on: ubuntu-latest + + steps: + - uses: ljharb/require-allow-edits@main From 6ee186bd39199a1c05421e200b1e8e31a83cf363 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 20 Oct 2023 13:30:03 -0700 Subject: [PATCH 09/18] [meta] update `.gitignore` from default branch --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index c77d1b6..058a156 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,6 @@ node_modules npm-shrinkwrap.json package-lock.json yarn.lock + +coverage +.nyc_output From e0770e594ec683ded32fd1b14e876f087fc04f4a Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 20 Oct 2023 13:30:57 -0700 Subject: [PATCH 10/18] [meta] use `npmignore` to autogenerate an npmignore file --- .gitignore | 2 ++ package.json | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/.gitignore b/.gitignore index 058a156..e1249a8 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,5 @@ yarn.lock coverage .nyc_output + +.npmignore diff --git a/package.json b/package.json index 09c3659..0037562 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,7 @@ "test": "test" }, "scripts": { + "prepack": "npmignore --auto --commentLines=autogenerated", "prepublishOnly": "safe-publish-latest", "prepublish": "not-in-publish || npm run prepublishOnly", "pretest": "npm run lint", @@ -32,6 +33,7 @@ "auto-changelog": "^2.4.0", "eslint": "=8.8.0", "in-publish": "^2.0.1", + "npmignore": "^0.3.0", "safe-publish-latest": "^2.0.0", "tape": "^5.7.1" }, @@ -86,5 +88,10 @@ "commitLimit": false, "backfillLimit": false, "hideCredit": true + }, + "publishConfig": { + "ignore": [ + ".github/workflows" + ] } } From e25bc3716c7ec0390b06bd7b6fac0c9ab0968ab4 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 20 Oct 2023 13:31:53 -0700 Subject: [PATCH 11/18] [Tests] add `nyc` for coverage --- .nycrc | 17 +++++++++++++++++ package.json | 10 ++++++---- 2 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 .nycrc diff --git a/.nycrc b/.nycrc new file mode 100644 index 0000000..5869cdb --- /dev/null +++ b/.nycrc @@ -0,0 +1,17 @@ +{ + "extension": [ + ".js", + ".cjs", + ".mjs" + ], + "all": true, + "check-coverage": false, + "reporter": ["text-summary", "text", "html", "json", "lcov"], + "exclude": [ + "coverage", + "example", + "test" + ], + "sourceMap": true, + "instrument": true +} diff --git a/package.json b/package.json index 0037562..ced940f 100644 --- a/package.json +++ b/package.json @@ -10,13 +10,13 @@ }, "scripts": { "prepack": "npmignore --auto --commentLines=autogenerated", - "prepublishOnly": "safe-publish-latest", "prepublish": "not-in-publish || npm run prepublishOnly", + "prepublishOnly": "safe-publish-latest", "pretest": "npm run lint", - "lint": "eslint .", - "tests-only": "tape test/*", + "lint": "eslint --ext=js,mjs .", + "tests-only": "nyc tape 'test/**/*.js'", "test": "npm run tests-only", - "posttest": "npx aud", + "posttest": "aud --production", "version": "auto-changelog && git add CHANGELOG.md", "postversion": "auto-changelog && git add CHANGELOG.md && git commit --no-edit --amend && git tag -f \"v$(node -e \"console.log(require('./package.json').version)\")\"" }, @@ -30,10 +30,12 @@ }, "devDependencies": { "@ljharb/eslint-config": "^21.1.0", + "aud": "^2.0.3", "auto-changelog": "^2.4.0", "eslint": "=8.8.0", "in-publish": "^2.0.1", "npmignore": "^0.3.0", + "nyc": "^10.3.2", "safe-publish-latest": "^2.0.0", "tape": "^5.7.1" }, From a269c183bccb78dfdd2c88a149fe5373f13af4c0 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 20 Oct 2023 13:33:18 -0700 Subject: [PATCH 12/18] [meta] fix URLs --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ced940f..292fb6b 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ }, "repository": { "type": "git", - "url": "http://github.com/substack/node-deep-equal.git" + "url": "http://github.com/inspect-js/node-deep-equal.git" }, "keywords": [ "equality", From 270d34b48401ee40792bf18d06614044246776dd Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 6 Nov 2023 22:49:43 -0800 Subject: [PATCH 13/18] [Dev Deps] update `tape` --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 292fb6b..34dbd15 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "npmignore": "^0.3.0", "nyc": "^10.3.2", "safe-publish-latest": "^2.0.0", - "tape": "^5.7.1" + "tape": "^5.7.2" }, "repository": { "type": "git", From e02cadb650ef9d75684c015a35d2c59e029d5174 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 6 Nov 2023 22:49:28 -0800 Subject: [PATCH 14/18] [Tests] port tests from main; only diff should be true/falses --- .eslintrc | 6 + .github/workflows/node-assert.yml | 65 -- assert.js | 3 + package.json | 6 + test/_tape.js | 27 +- test/cmp.js | 1080 +++++++++++++++++++++++++++-- 6 files changed, 1074 insertions(+), 113 deletions(-) delete mode 100644 .github/workflows/node-assert.yml create mode 100644 assert.js diff --git a/.eslintrc b/.eslintrc index 427143f..80a395d 100644 --- a/.eslintrc +++ b/.eslintrc @@ -13,7 +13,13 @@ "overrides": [ { "files": ["example/**", "test/**"], + "globals": { + "Uint8Array": false, + "Int8Array": false, + }, "rules": { + "id-length": 0, + "max-lines-per-function": 0, "max-params": 0, "no-console": 0, }, diff --git a/.github/workflows/node-assert.yml b/.github/workflows/node-assert.yml deleted file mode 100644 index 112419d..0000000 --- a/.github/workflows/node-assert.yml +++ /dev/null @@ -1,65 +0,0 @@ -name: 'Tests: node.js `assert`' - -on: [pull_request, push] - -jobs: - matrix: - runs-on: ubuntu-latest - outputs: - requireds: ${{ steps.set-matrix.outputs.requireds }} - optionals: ${{ steps.set-matrix.outputs.optionals }} - steps: - - uses: ljharb/actions/node/matrix@main - id: set-matrix - with: - type: 'majors' - requireds: '^12.16 || >= 13.4' - optionals: '>= 8 < 12.16 || ^13.0 < 13.4' - - assert-required: - needs: [matrix] - name: 'assert: required' - runs-on: ubuntu-latest - - strategy: - fail-fast: false - matrix: ${{ fromJson(needs.matrix.outputs.requireds) }} - - steps: - - uses: actions/checkout@v2 - - uses: ljharb/actions/node/install@main - name: 'nvm install ${{ matrix.node-version }} && npm install' - with: - node-version: ${{ matrix.node-version }} - - run: npm run tests-only - env: - ASSERT: true - - uses: codecov/codecov-action@v2 - - assert-optional: - needs: [matrix] - name: 'assert: optional' - runs-on: ubuntu-latest - continue-on-error: true - - strategy: - fail-fast: false - matrix: ${{ fromJson(needs.matrix.outputs.optionals) }} - - steps: - - uses: actions/checkout@v2 - - uses: ljharb/actions/node/install@main - name: 'nvm install ${{ matrix.node-version }} && npm install' - with: - node-version: ${{ matrix.node-version }} - - run: npm run tests-only - env: - ASSERT: true - - uses: codecov/codecov-action@v2 - - assert: - name: 'node: assert' - needs: [assert-required, assert-optional] - runs-on: ubuntu-latest - steps: - - run: 'echo tests completed' diff --git a/assert.js b/assert.js new file mode 100644 index 0000000..fffb7b8 --- /dev/null +++ b/assert.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('assert'); diff --git a/package.json b/package.json index 34dbd15..d3e37ad 100644 --- a/package.json +++ b/package.json @@ -33,10 +33,13 @@ "aud": "^2.0.3", "auto-changelog": "^2.4.0", "eslint": "=8.8.0", + "has-typed-arrays": "^1.0.1", "in-publish": "^2.0.1", "npmignore": "^0.3.0", "nyc": "^10.3.2", + "object.getownpropertydescriptors": "^2.1.7", "safe-publish-latest": "^2.0.0", + "semver": "^6.3.1", "tape": "^5.7.2" }, "repository": { @@ -91,6 +94,9 @@ "backfillLimit": false, "hideCredit": true }, + "browser": { + "assert.js": false + }, "publishConfig": { "ignore": [ ".github/workflows" diff --git a/test/_tape.js b/test/_tape.js index d359d4b..cb1fb4b 100644 --- a/test/_tape.js +++ b/test/_tape.js @@ -1,13 +1,34 @@ +'use strict'; + var Test = require('tape/lib/test'); var is = require('object-is'); -var equal = require('../'); + +var deepEqual = require('../'); +var assert = require('../assert'); + +var equal = process.env.ASSERT ? function assertDeepEqual(a, b, options) { + try { + if (options && options.strict) { + assert.deepStrictEqual(a, b); + } else { + assert.deepEqual(a, b); + } + } catch (e) { + return false; + } + return true; +} : deepEqual; function equalReversed(t, a, b, isEqual, msg, isStrict, skipReversed) { - var actual = isStrict ? equal(a, b, { strict: true }) : equal(a, b); + var actual = isStrict + ? equal(a, b, { strict: true }) + : equal(a, b); var suffix = isEqual ? ' are equal' : ' are not equal'; t.equal(actual, !!isEqual, msg + suffix); if (typeof skipReversed === 'boolean' ? !skipReversed : !is(a, b)) { - var actualReverse = isStrict ? equal(b, a, { strict: true }) : equal(b, a); + var actualReverse = isStrict + ? equal(b, a, { strict: true }) + : equal(b, a); t.equal(actualReverse, !!isEqual, msg + suffix + ' (reversed)'); } } diff --git a/test/cmp.js b/test/cmp.js index ab24bee..ed7233e 100644 --- a/test/cmp.js +++ b/test/cmp.js @@ -1,7 +1,30 @@ +'use strict'; + var test = require('tape'); require('./_tape'); +var assign = require('object.assign'); +var gOPDs = require('object.getownpropertydescriptors'); +var hasSymbols = require('has-symbols')(); +var hasTypedArrays = require('has-typed-arrays')(); +var semver = require('semver'); +var keys = require('object-keys'); +var availableTypedArrays = require('available-typed-arrays')(); +var forEach = require('for-each'); +var hasProto = require('has-proto')(); + +var safeBuffer = typeof Buffer === 'function' ? Buffer.from && Buffer.from.length > 1 ? Buffer.from : Buffer : null; +var buffersAreTypedArrays = typeof Buffer === 'function' && new Buffer(0) instanceof Uint8Array; -var equal = require('../'); +var isNode = typeof process === 'object' && typeof process.version === 'string'; + +function tag(obj, value) { + if (hasSymbols && Symbol.toStringTag && Object.defineProperty) { + Object.defineProperty(obj, Symbol.toStringTag, { + value: value + }); + } + return obj; +} test('equal', function (t) { t.deepEqualTest( @@ -12,6 +35,298 @@ test('equal', function (t) { true, false ); + + var obj1 = { a: [2, 3], b: [4] }; + var obj2 = { b: [4], a: [2, 3] }; + t.notDeepEqual(keys(obj1), keys(obj2), 'keys are in a different order'); + t.deepEqual(keys(obj1), keys(obj2).reverse(), 'keys are in opposite order'); + t.deepEqualTest( + obj1, + obj2, + 'two equal objects, in different order', + true, + true + ); + + t.deepEqualTest( + { a: 2, b: '4' }, + { a: 2, b: 4 }, + 'two loosely equal, strictly inequal objects', + true, + false + ); + + t.deepEqualTest( + { a: 2, b: 4 }, + { a: 2, B: 4 }, + 'two inequal objects', + false, + false + ); + + t.deepEqualTest( + '-000', + false, + '`false` and `"-000"`', + true, + false + ); + + t.end(); +}); + +test('Maps', { skip: typeof Map !== 'function' }, function (t) { + t.deepEqualTest( + new Map([['a', 1], ['b', 2]]), + new Map([['b', 2], ['a', 1]]), + 'two equal Maps', + true, + true + ); + + t.deepEqualTest( + new Map([['a', [1, 2]]]), + new Map([['a', [2, 1]]]), + 'two Maps with inequal values on the same key', + true, + true + ); + + t.deepEqualTest( + new Map([['a', 1]]), + new Map([['b', 1]]), + 'two inequal Maps', + true, + true + ); + + t.deepEqualTest( + new Map([[{}, 3], [{}, 2], [{}, 1]]), + new Map([[{}, 1], [{}, 2], [{}, 3]]), + 'two equal Maps in different orders with object keys', + true, + true + ); + + t.deepEqualTest( + new Map([[undefined, undefined]]), + new Map([[undefined, null]]), + 'undefined keys, nullish values, loosely equal, strictly inequal', + true, + true + ); + + t.deepEqualTest( + new Map([[{}, null], [true, 2], [{}, 1], [undefined, {}]]), + new Map([[{}, 1], [true, 2], [{}, null], [undefined, {}]]), + 'two equal Maps in different orders with primitive keys', + true, + true + ); + + t.deepEqualTest( + new Map([[false, 3], [{}, 2], [{}, 1]]), + new Map([[{}, 1], [{}, 2], [false, 3]]), + 'two equal Maps in different orders with a mix of keys', + true, + true + ); + + t.deepEqualTest( + new Map([[null, undefined]]), + new Map([[null, null]]), + 'null keys, nullish values, loosely equal, strictly inequal', + true, + true + ); + + t.deepEqualTest( + new Map([[undefined, 3]]), + new Map([[null, 3]]), + 'nullish keys, loosely equal, strictly inequal', + true, + true + ); + + t.deepEqualTest( + new Map([[{}, null], [true, 2], [{}, 1], [undefined, {}]]), + new Map([[{}, 1], [true, 2], [{}, null], [undefined, {}]]), + 'two equal Maps in different orders with primitive keys', + true, + true + ); + + t.deepEqualTest( + new Map([[false, 3], [{}, 2], [{}, 1]]), + new Map([[{}, 1], [{}, 2], [false, 3]]), + 'two equal Maps in different orders with a mix of keys', + true, + true + ); + + t.deepEqualTest( + new Map(), + new Map([[{}, 1]]), + 'two inequal Maps', + true, + true + ); + + t.deepEqualTest( + new Map([[{}, null], [false, 3]]), + new Map([[{}, null], [true, 2]]), + 'two inequal maps, same size, primitive key, start with object key', + true, + true + ); + + t.deepEqualTest( + new Map([[false, 3], [{}, null]]), + new Map([[true, 2], [{}, null]]), + 'two inequal maps, same size, primitive key, start with primitive key', + true, + true + ); + + t.deepEqualTest( + new Map([[undefined, null], ['+000', 2]]), + new Map([[null, undefined], [false, '2']]), + 'primitive comparisons', + true, + true + ); + + t.end(); +}); + +test('WeakMaps', { skip: typeof WeakMap !== 'function' }, function (t) { + t.deepEqualTest( + new WeakMap([[Object, null], [Function, true]]), + new WeakMap([[Function, true], [Object, null]]), + 'two equal WeakMaps', + true, + true + ); + + t.deepEqualTest( + new WeakMap([[Object, null]]), + new WeakMap([[Object, true]]), + 'two WeakMaps with inequal values on the same key', + true, + true + ); + + t.deepEqualTest( + new WeakMap([[Object, null], [Function, true]]), + new WeakMap([[Object, null]]), + 'two inequal WeakMaps', + true, + true + ); + + t.end(); +}); + +test('Sets', { skip: typeof Set !== 'function' }, function (t) { + t.deepEqualTest( + new Set(['a', 1, 'b', 2]), + new Set(['b', 2, 'a', 1]), + 'two equal Sets', + true, + true + ); + + t.deepEqualTest( + new Set(['a', 1]), + new Set(['b', 1]), + 'two inequal Sets', + true, + true + ); + + t.deepEqualTest( + new Set([{}, 1, {}, {}, 2]), + new Set([{}, 1, {}, 2, {}]), + 'two equal Sets in different orders', + true, + true + ); + + t.deepEqualTest( + new Set(), + new Set([1]), + 'two inequally sized Sets', + true, + true + ); + + t.deepEqualTest( + new Set([{ a: 1 }, 2]), + new Set(['2', { a: '1' }]), + 'two loosely equal, strictly inequal Sets', + true, + true + ); + + t.deepEqualTest( + new Set([{ a: 1 }, 2]), + new Set(['2', { a: 2 }]), + 'two inequal Sets', + true, + true + ); + + t.deepEqualTest( + new Set([null, '', 1, 5, 2, false]), + new Set([undefined, 0, '5', true, '2', '-000']), + 'more primitive comparisons', + true, + true + ); + + t.end(); +}); + +test('Set and Map', { skip: !Object.defineProperty || typeof Set !== 'function' || typeof Map !== 'function' }, function (t) { + t.deepEqualTest( + new Set(), + new Map(), + 'Map and Set', + true, + true + ); + + var maplikeSet = new Set(); + Object.defineProperty(maplikeSet, 'constructor', { enumerable: false, value: Map }); + maplikeSet.__proto__ = Map.prototype; // eslint-disable-line no-proto + t.deepEqualTest( + maplikeSet, + new Map(), + 'Map-like Set, and Map', + true, + true + ); + + t.end(); +}); + +test('WeakSets', { skip: typeof WeakSet !== 'function' }, function (t) { + t.deepEqualTest( + new WeakSet([Object, Function]), + new WeakSet([Function, Object]), + 'two equal WeakSets', + true, + true + ); + + t.deepEqualTest( + new WeakSet([Object, Function]), + new WeakSet([Object]), + 'two inequal WeakSets', + true, + true + ); + t.end(); }); @@ -23,6 +338,7 @@ test('not equal', function (t) { false, false ); + t.end(); }); @@ -71,9 +387,14 @@ test('arguments class', function (t) { function getArgs() { return arguments; } - t.ok( - equal(getArgs(1, 2, 3), getArgs(1, 2, 3)), - 'equivalent arguments objects are equal' + + t.deepEqualTest( + getArgs(1, 2, 3), + getArgs(1, 2, 3), + 'equivalent arguments objects are equal', + true, + true, + true ); t.deepEqualTest( @@ -84,27 +405,103 @@ test('arguments class', function (t) { false ); + var args = getArgs(); + var notArgs = tag({ length: 0 }, 'Arguments'); + t.deepEqualTest( + args, + notArgs, + 'args and similar arraylike object', + false, + false + ); + t.end(); }); -test('dates', function (t) { +test('Dates', function (t) { var d0 = new Date(1387585278000); var d1 = new Date('Fri Dec 20 2013 16:21:18 GMT-0800 (PST)'); - t.deepEqualTest(d0, d1, 'equivalent Dates', true, true); + + t.deepEqualTest(d0, d1, 'two Dates with the same timestamp', true, true); + + d1.a = true; + + t.deepEqualTest(d0, d1, 'two Dates with the same timestamp but different own properties', true, true); + + t.test('overriding `getTime`', { skip: !Object.defineProperty }, function (st) { + var a = new Date('2000'); + var b = new Date('2000'); + Object.defineProperty(a, 'getTime', { value: function () { return 5; } }); + st.deepEqualTest(a, b, 'two Dates with the same timestamp but one has overridden `getTime`', true, true); + st.end(); + }); + + t.test('fake Date', { skip: !hasProto }, function (st) { + var a = new Date(2000); + var b = tag(Object.create( + a.__proto__, // eslint-disable-line no-proto + gOPDs(a) + ), 'Date'); + + st.deepEqualTest( + a, + b, + 'Date, and fake Date', + true, + true + ); + + st.end(); + }); + + var a = new Date('2000'); + var b = new Date('2000'); + b.foo = true; + t.deepEqualTest( + a, + b, + 'two identical Dates, one with an extra property', + true, + true + ); + + t.deepEqualTest( + new Date('2000'), + new Date('2001'), + 'two inequal Dates', + false, + false + ); + t.end(); }); test('buffers', { skip: typeof Buffer !== 'function' }, function (t) { - var safeBuffer = Buffer.from && Buffer.from.length > 1 ? Buffer.from : Buffer; + /* eslint no-buffer-constructor: 1, new-cap: 1 */ t.deepEqualTest( safeBuffer('xyz'), safeBuffer('xyz'), 'buffers with same contents are equal', true, - true, true ); + t.deepEqualTest( + safeBuffer('xyz'), + safeBuffer('xyy'), + 'buffers with same length and different contents are inequal', + false, + false + ); + + t.deepEqualTest( + safeBuffer('xyz'), + safeBuffer('xy'), + 'buffers with different length are inequal', + false, + false + ); + t.deepEqualTest( safeBuffer('abc'), safeBuffer('xyz'), @@ -113,14 +510,108 @@ test('buffers', { skip: typeof Buffer !== 'function' }, function (t) { false ); + var emptyBuffer = safeBuffer(''); + t.deepEqualTest( - safeBuffer(''), + emptyBuffer, [], 'empty buffer and empty array', false, false ); + t.test('bufferlikes', { skip: !Object.defineProperty || !hasTypedArrays }, function (st) { + var fakeBuffer = { + 0: 'a', + length: 1, + __proto__: emptyBuffer.__proto__, // eslint-disable-line no-proto + copy: emptyBuffer.copy, + slice: emptyBuffer.slice + }; + Object.defineProperty(fakeBuffer, '0', { enumerable: false }); + Object.defineProperty(fakeBuffer, 'length', { enumerable: false }); + Object.defineProperty(fakeBuffer, 'copy', { enumerable: false }); + Object.defineProperty(fakeBuffer, 'slice', { enumerable: false }); + + st.deepEqualTest( + safeBuffer('a'), + fakeBuffer, + 'real buffer, and mildly fake buffer', + false, + false + ); + + st.test('bufferlike', { skip: buffersAreTypedArrays ? !hasSymbols || !Symbol.toStringTag : false }, function (s2t) { + var bufferlike = buffersAreTypedArrays ? new Uint8Array() : {}; + Object.defineProperty(bufferlike, 'length', { + enumerable: false, + value: bufferlike.length || 0 + }); + Object.defineProperty(bufferlike, 'copy', { + enumerable: false, + value: emptyBuffer.copy + }); + bufferlike.__proto__ = emptyBuffer.__proto__; // eslint-disable-line no-proto + + s2t.deepEqualTest( + emptyBuffer, + bufferlike, + 'empty buffer and empty bufferlike', + true, + true + ); + s2t.end(); + }); + + st.end(); + }); + + t.end(); +}); + +test('Arrays', function (t) { + var a = []; + var b = []; + b.foo = true; + + t.deepEqualTest( + a, + b, + 'two identical arrays, one with an extra property', + false, + false + ); + + t.end(); +}); + +test('booleans', function (t) { + t.deepEqualTest( + true, + true, + 'trues', + true, + true, + false + ); + + t.deepEqualTest( + false, + false, + 'falses', + true, + true, + false + ); + + t.deepEqualTest( + true, + false, + 'true and false', + false, + false + ); + t.end(); }); @@ -144,39 +635,45 @@ test('booleans and arrays', function (t) { test('arrays initiated', function (t) { var a0 = [ - undefined, - null, - -1, - 0, - 1, - false, - true, - undefined, - '', - 'abc', - null, - undefined - ], - a1 = [ - undefined, - null, - -1, - 0, - 1, - false, - true, - undefined, - '', - 'abc', - null, - undefined - ]; + undefined, + null, + -1, + 0, + 1, + false, + true, + undefined, + '', + 'abc', + null, + undefined + ]; + var a1 = [ + undefined, + null, + -1, + 0, + 1, + false, + true, + undefined, + '', + 'abc', + null, + undefined + ]; - t.ok(equal(a0, a1)); + t.deepEqualTest( + a0, + a1, + 'arrays with equal contents are equal', + true, + true, + true + ); t.end(); }); -// eslint-disable-next-line max-statements test('arrays assigned', function (t) { var a0 = [ undefined, @@ -212,7 +709,6 @@ test('arrays assigned', function (t) { t.end(); }); -// eslint-disable-next-line max-statements test('arrays push', function (t) { var a0 = [ undefined, @@ -250,19 +746,31 @@ test('arrays push', function (t) { test('null == undefined', function (t) { t.deepEqualTest(null, undefined, 'null and undefined', true, false); + t.deepEqualTest([null], [undefined], '[null] and [undefined]', true, false); t.end(); }); +// node 14 changed `deepEqual` to make two NaNs loosely equal. TODO, semver-major: change deep-equal in the same way. +var isNode14 = isNode && process.env.ASSERT && semver.satisfies(process.version, '>= 14'); test('NaNs', function (t) { - t.notOk(equal(NaN, NaN), 'NaN is not NaN'); - t.ok(equal(NaN, NaN, { strict: true }), 'strict: NaN is NaN'); + t.deepEqualTest( + NaN, + NaN, + 'two NaNs', + isNode14, + true + ); - t.notOk(equal({ a: NaN }, { a: NaN }), 'two equiv objects with a NaN value are not equiv'); - t.ok(equal({ a: NaN }, { a: NaN }, { strict: true }), 'strict: two equiv objects with a NaN value are equiv'); + t.deepEqualTest( + { a: NaN }, + { a: NaN }, + 'two equiv objects with a NaN value', + isNode14, + true + ); - t.notOk(equal(NaN, 1), 'NaN !== 1'); - t.notOk(equal(NaN, 1, { strict: true }), 'strict: NaN !== 1'); + t.deepEqualTest(NaN, 1, 'NaN and 1', false, false); t.end(); }); @@ -329,6 +837,51 @@ test('regexen', function (t) { t.deepEqualTest(/abc/, /abc/, 'two abc regexes', true, true, false); t.deepEqualTest(/xyz/, /xyz/, 'two xyz regexes', true, true, false); + t.test('fake RegExp', { skip: !hasProto }, function (st) { + var a = /abc/g; + var b = tag(Object.create( + a.__proto__, // eslint-disable-line no-proto + gOPDs(a) + ), 'RegExp'); + + st.deepEqualTest(a, b, 'regex and fake regex', false, false); + + st.end(); + }); + + var a = /abc/gi; + var b = /abc/gi; + b.foo = true; + t.deepEqualTest( + a, + b, + 'two identical regexes, one with an extra property', + true, + true + ); + + var c = /abc/g; + var d = /abc/i; + t.deepEqualTest( + c, + d, + 'two regexes with the same source but different flags', + false, + false + ); + + t.end(); +}); + +test('object literals', function (t) { + t.deepEqualTest( + { prototype: 2 }, + { prototype: '2' }, + 'two loosely equal, strictly inequal prototype properties', + false, + false + ); + t.end(); }); @@ -344,7 +897,444 @@ test('functions', function (t) { function f() {} t.deepEqualTest(f, f, 'a function and itself', true, true, true); + t.deepEqualTest([f], [f], 'a function and itself in an array', true, true, true); + t.deepEqualTest(function () {}, function () {}, 'two distinct functions', false, false, true); + t.deepEqualTest([function () {}], [function () {}], 'two distinct functions in an array', false, false, true); + + t.deepEqualTest(f, {}, 'function and object', false, false, true); + t.deepEqualTest([f], [{}], 'function and object in an array', false, false, true); + + t.end(); +}); + +test('Errors', function (t) { + t.deepEqualTest(new Error('xyz'), new Error('xyz'), 'two errors of the same type with the same message', true, true, false); + t.deepEqualTest(new Error('xyz'), new TypeError('xyz'), 'two errors of different types with the same message', true, true); + t.deepEqualTest(new Error('xyz'), new Error('zyx'), 'two errors of the same type with a different message', true, true); + + t.test('errorlike', { skip: !Object.defineProperty }, function (st) { + var err = new Error('foo'); + // TODO: add `__proto__` when brand check is available + var errorlike = tag({ message: err.message, stack: err.stack, name: err.name, constructor: err.constructor }, 'Error'); + Object.defineProperty(errorlike, 'message', { enumerable: false }); + Object.defineProperty(errorlike, 'stack', { enumerable: false }); + Object.defineProperty(errorlike, 'name', { enumerable: false }); + Object.defineProperty(errorlike, 'constructor', { enumerable: false }); + st.notOk(errorlike instanceof Error); + st.ok(err instanceof Error); + st.deepEqualTest( + err, + errorlike, + 'error, and errorlike object', + true, + true + ); + + st.end(); + }); + + t.deepEqualTest( + new Error('a'), + assign(new Error('a'), { code: 10 }), + 'two otherwise equal errors with different own properties', + false, + false + ); + + t.test('fake error', { skip: !process.env.ASSERT || !hasProto }, function (st) { + var a = tag({ + __proto__: null + }, 'Error'); + var b = new RangeError('abc'); + b.__proto__ = null; // eslint-disable-line no-proto + + st.deepEqualTest( + a, + b, + 'null object faking as an Error, RangeError with null proto', + false, + false + ); + st.end(); + }); + + t.end(); +}); + +test('object and null', function (t) { + t.deepEqualTest( + {}, + null, + 'null and an object', + false, + false + ); + + t.end(); +}); + +test('errors', function (t) { + + t.end(); +}); + +test('error = Object', function (t) { + t.deepEqualTest( + new Error('a'), + { message: 'a' }, + false, + false + ); + + t.end(); +}); + +test('[[Prototypes]]', function (t) { + function C() {} + var instance = new C(); + delete instance.constructor; + + t.deepEqualTest({}, instance, 'two identical objects with different [[Prototypes]]', true, true); + + t.test('Dates with different prototypes', { skip: !hasProto }, function (st) { + var d1 = new Date(0); + var d2 = new Date(0); + + st.deepEqualTest(d1, d2, 'two dates with the same timestamp', true, true); + + var newProto = { + __proto__: Date.prototype + }; + d2.__proto__ = newProto; // eslint-disable-line no-proto + st.ok(d2 instanceof Date, 'd2 is still a Date instance after tweaking [[Prototype]]'); + + st.deepEqualTest(d1, d2, 'two dates with the same timestamp and different [[Prototype]]', true, true); + + st.end(); + }); + + t.end(); +}); + +test('toStringTag', { skip: !hasSymbols || !Symbol.toStringTag }, function (t) { + var o1 = {}; + t.equal(Object.prototype.toString.call(o1), '[object Object]', 'o1: Symbol.toStringTag works'); + + var o2 = {}; + t.equal(Object.prototype.toString.call(o2), '[object Object]', 'o2: original Symbol.toStringTag works'); + + t.deepEqualTest(o1, o2, 'two normal empty objects', true, true); + + o2[Symbol.toStringTag] = 'jifasnif'; + t.equal(Object.prototype.toString.call(o2), '[object jifasnif]', 'o2: modified Symbol.toStringTag works'); + + t.deepEqualTest(o1, o2, 'two normal empty objects with different toStringTags', true, true); + + t.end(); +}); + +test('boxed primitives', function (t) { + t.deepEqualTest(Object(false), false, 'boxed and primitive `false`', true, false); + t.deepEqualTest(Object(true), true, 'boxed and primitive `true`', false, false); + t.deepEqualTest(Object(3), 3, 'boxed and primitive `3`', false, false); + t.deepEqualTest(Object(NaN), NaN, 'boxed and primitive `NaN`', false, false); + t.deepEqualTest(Object(''), '', 'boxed and primitive `""`', true, false); + t.deepEqualTest(Object('str'), 'str', 'boxed and primitive `"str"`', false, false); + + t.test('symbol', { skip: !hasSymbols }, function (st) { + var s = Symbol(''); + st.deepEqualTest(Object(s), s, 'boxed and primitive `Symbol()`', false, false); + st.end(); + }); + + t.test('bigint', { skip: typeof BigInt !== 'function' }, function (st) { + var hhgtg = BigInt(42); + st.deepEqualTest(Object(hhgtg), hhgtg, 'boxed and primitive `BigInt(42)`', false, false); + st.end(); + }); + + t.test('`valueOf` is called for boxed primitives', function (st) { + var a = Object(5); + a.valueOf = function () { throw new Error('failed'); }; + var b = Object(5); + b.valueOf = function () { throw new Error('failed'); }; + + st.deepEqualTest(a, b, 'two boxed numbers with a thrower valueOf', false, false); + + st.end(); + }); + + t.end(); +}); + +test('getters', { skip: !Object.defineProperty }, function (t) { + var a = {}; + Object.defineProperty(a, 'a', { enumerable: true, get: function () { return 5; } }); + var b = {}; + Object.defineProperty(b, 'a', { enumerable: true, get: function () { return 6; } }); + + t.deepEqualTest(a, b, 'two objects with the same getter but producing different values', false, false); + + t.end(); +}); + +var isBrokenNode = isNode && process.env.ASSERT && semver.satisfies(process.version, '<= 13.3.0'); +test('fake arrays: extra keys will be tested', { skip: !hasProto || isBrokenNode }, function (t) { + var a = tag({ + __proto__: Array.prototype, + 0: 1, + 1: 1, + 2: 'broken', + length: 2 + }, 'Array'); + if (Object.defineProperty) { + Object.defineProperty(a, 'length', { + enumerable: false + }); + } + + t.deepEqualTest(a, [1, 1], 'fake and real array with same contents and [[Prototype]]', false, false); + + var b = tag(/abc/, 'Array'); + b.__proto__ = Array.prototype; // eslint-disable-line no-proto + b.length = 3; + if (Object.defineProperty) { + Object.defineProperty(b, 'length', { + enumerable: false + }); + } + t.deepEqualTest(b, ['a', 'b', 'c'], 'regex faking as array, and array', false, false); + + t.end(); +}); + +test('circular references', { skip: 'not supported until v2' }, function (t) { + var b = {}; + b.b = b; + + var c = {}; + c.b = c; + + t.deepEqualTest( + b, + c, + 'two self-referencing objects', + true, + true + ); + + var d = {}; + d.a = 1; + d.b = d; + + var e = {}; + e.a = 1; + e.b = e.a; + + t.deepEqualTest( + d, + e, + 'two deeply self-referencing objects', + false, + false + ); + + t.end(); +}); + +// io.js v2 is the only version where `console.log(b)` below is catchable +var isNodeWhereBufferBreaks = isNode && semver.satisfies(process.version, '< 3'); +var isNode06 = isNode && semver.satisfies(process.version, '<= 0.6'); // segfaults in node 0.6, it seems + +test('TypedArrays', { skip: !hasTypedArrays }, function (t) { + t.test('Buffer faked as Uint8Array', { skip: typeof Buffer !== 'function' || !Object.create || !hasProto || isNode06 }, function (st) { + var a = safeBuffer('test'); + var b = tag(Object.create( + a.__proto__, // eslint-disable-line no-proto + assign(gOPDs(a), { + length: { + enumerable: false, + value: 4 + } + }) + ), 'Uint8Array'); + + st.deepEqualTest( + a, + b, + 'Buffer and Uint8Array', + true || isNodeWhereBufferBreaks, + true || isNodeWhereBufferBreaks + ); + + st.end(); + }); + + forEach(availableTypedArrays, function (name) { + t.test(name + 's', function (st) { + var TA = global[name]; + var isBigInt = name.slice(0, 3) === 'Big'; + var Z = isBigInt ? BigInt : Number; + + st.deepEqualTest( + new TA([Z(1), Z(2), Z(3)]), + new TA([Z(1), Z(2), Z(3)]), + 'two ' + name + 's with the same contents', + true, + true + ); + + st.deepEqualTest( + new TA([Z(1), Z(2), Z(3)]), + new TA([Z(1), Z(2), Z(4)]), + 'two ' + name + 's with different contents', + false, + false + ); + + st.end(); + }); + }); + + t.test('one TypedArray faking as another', { skip: !hasProto }, function (st) { + var a = new Uint8Array(10); + var b = tag(new Int8Array(10), 'Uint8Array'); + b.__proto__ = Uint8Array.prototype; // eslint-disable-line no-proto + + st.deepEqualTest( + a, + b, + 'Uint8Array, and Int8Array pretending to be a Uint8Array', + true, + true + ); + + st.end(); + }); + + t.test('ArrayBuffers', { skip: typeof ArrayBuffer !== 'function' }, function (st) { + var buffer1 = new ArrayBuffer(8); // initial value of 0's + var buffer2 = new ArrayBuffer(8); // initial value of 0's + + var view1 = new Int8Array(buffer1); + var view2 = new Int8Array(buffer2); + + st.deepEqualTest( + view1, + view2, + 'Int8Arrays of similar ArrayBuffers', + true, + true + ); + + st.deepEqualTest( + buffer1, + buffer2, + 'similar ArrayBuffers', + true, + true + ); + + for (var i = 0; i < view1.byteLength; i += 1) { + view1[i] = 9; // change all values to 9's + } + + st.deepEqualTest( + view1, + view2, + 'Int8Arrays of different ArrayBuffers', + false, + false + ); + + st.deepEqualTest( + buffer1, + buffer2, + 'different ArrayBuffers', + true, + true + ); + + // node < 0.11 has a nonconfigurable own byteLength property + t.test('lies about byteLength', { skip: !('byteLength' in ArrayBuffer.prototype) }, function (s2t) { + var empty4 = new ArrayBuffer(4); + var empty6 = new ArrayBuffer(6); + Object.defineProperty(empty6, 'byteLength', { value: 4 }); + + s2t.deepEqualTest( + empty4, + empty6, + 'different-length ArrayBuffers, one lying', + true, + true + ); + s2t.end(); + }); + + st.end(); + }); + + t.test('SharedArrayBuffers', { skip: typeof SharedArrayBuffer !== 'function' }, function (st) { + var buffer1 = new SharedArrayBuffer(8); // initial value of 0's + var buffer2 = new SharedArrayBuffer(8); // initial value of 0's + + var view1 = new Int8Array(buffer1); + var view2 = new Int8Array(buffer2); + + st.deepEqualTest( + view1, + view2, + 'Int8Arrays of similar SharedArrayBuffers', + true, + true + ); + + st.deepEqualTest( + buffer1, + buffer2, + 'similar SharedArrayBuffers', + true, + true + ); + + for (var i = 0; i < view1.byteLength; i += 1) { + view1[i] = 9; // change all values to 9's + } + + st.deepEqualTest( + view1, + view2, + 'Int8Arrays of different SharedArrayBuffers', + false, + false + ); + + st.deepEqualTest( + buffer1, + buffer2, + 'different SharedArrayBuffers', + true, + true + ); + + t.test('lies about byteLength', { skip: !('byteLength' in SharedArrayBuffer.prototype) }, function (s2t) { + var empty4 = new SharedArrayBuffer(4); + var empty6 = new SharedArrayBuffer(6); + Object.defineProperty(empty6, 'byteLength', { value: 4 }); + + s2t.deepEqualTest( + empty4, + empty6, + 'different-length SharedArrayBuffers, one lying', + true, + true + ); + s2t.end(); + }); + + st.end(); + }); t.end(); }); From 3798ff490286ee9ba70cf50c339914be355eea18 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 6 Nov 2023 22:54:07 -0800 Subject: [PATCH 15/18] [Tests] handle ported test failures in iojs v2 --- package.json | 1 + test/cmp.js | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index d3e37ad..4be72af 100644 --- a/package.json +++ b/package.json @@ -32,6 +32,7 @@ "@ljharb/eslint-config": "^21.1.0", "aud": "^2.0.3", "auto-changelog": "^2.4.0", + "define-data-property": "^1.1.1", "eslint": "=8.8.0", "has-typed-arrays": "^1.0.1", "in-publish": "^2.0.1", diff --git a/test/cmp.js b/test/cmp.js index ed7233e..3a01c21 100644 --- a/test/cmp.js +++ b/test/cmp.js @@ -11,6 +11,7 @@ var keys = require('object-keys'); var availableTypedArrays = require('available-typed-arrays')(); var forEach = require('for-each'); var hasProto = require('has-proto')(); +var defineDataProperty = require('define-data-property'); var safeBuffer = typeof Buffer === 'function' ? Buffer.from && Buffer.from.length > 1 ? Buffer.from : Buffer : null; var buffersAreTypedArrays = typeof Buffer === 'function' && new Buffer(0) instanceof Uint8Array; @@ -1201,13 +1202,14 @@ test('TypedArrays', { skip: !hasTypedArrays }, function (t) { var a = new Uint8Array(10); var b = tag(new Int8Array(10), 'Uint8Array'); b.__proto__ = Uint8Array.prototype; // eslint-disable-line no-proto + defineDataProperty(b, 'length', 10); st.deepEqualTest( a, b, 'Uint8Array, and Int8Array pretending to be a Uint8Array', - true, - true + false, + false ); st.end(); From e158993fcf913aca8a1ffdc037abfeeb3a5cb4e5 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 6 Nov 2023 22:56:11 -0800 Subject: [PATCH 16/18] [meta] add missing `engines.node` --- package.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/package.json b/package.json index 4be72af..ab66907 100644 --- a/package.json +++ b/package.json @@ -61,6 +61,9 @@ "url": "https://github.com/sponsors/ljharb" }, "license": "MIT", + "engines": { + "node": ">= 0.4" + }, "testling": { "files": "test/*.js", "browsers": { From 197a2203f0a95828c62ff2b3c980ddf16736913c Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Tue, 7 Nov 2023 09:18:07 -0800 Subject: [PATCH 17/18] [Tests] handle some additional test differences in node <= 0.10 --- test/cmp.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/cmp.js b/test/cmp.js index 3a01c21..7784832 100644 --- a/test/cmp.js +++ b/test/cmp.js @@ -1250,12 +1250,13 @@ test('TypedArrays', { skip: !hasTypedArrays }, function (t) { false ); + var isHigherThanNode010 = isNode && semver.satisfies(process.version, '> 0.10'); st.deepEqualTest( buffer1, buffer2, 'different ArrayBuffers', - true, - true + isHigherThanNode010, + isHigherThanNode010 ); // node < 0.11 has a nonconfigurable own byteLength property From be5f0362c99f4f205628f289a04f703a1023005f Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Wed, 8 Nov 2023 16:24:26 -0800 Subject: [PATCH 18/18] v1.1.2 --- CHANGELOG.md | 24 +++++++++++++++++++++++- package.json | 2 +- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a7394f1..7384d5e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -143,7 +143,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - [Fix] check extra properties on regexps [`1eac46b`](https://github.com/inspect-js/node-deep-equal/commit/1eac46b69c7b499cecb7e3b555b6e260de2043fd) - [Tests] update test skipping logic [`8adf08d`](https://github.com/inspect-js/node-deep-equal/commit/8adf08dcb91146590f2c57b614de6a853054f297) -## [v2.0.0](https://github.com/inspect-js/node-deep-equal/compare/v1.1.1...v2.0.0) - 2019-12-03 +## [v2.0.0](https://github.com/inspect-js/node-deep-equal/compare/v1.1.2...v2.0.0) - 2019-12-03 ### Fixed @@ -185,6 +185,28 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Merge tag 'v1.1.1' [`f9d3c6d`](https://github.com/inspect-js/node-deep-equal/commit/f9d3c6d1e4a895c448ba7d8766f8616d0e235c9a) - Merge tag 'v1.1.0' [`0aeca99`](https://github.com/inspect-js/node-deep-equal/commit/0aeca9988dba6fe3318f46c47c933e6926175278) +## [v1.1.2](https://github.com/inspect-js/node-deep-equal/compare/v1.1.1...v1.1.2) - 2023-11-08 + +### Commits + +- [Tests] port tests from main; only diff should be true/falses [`e02cadb`](https://github.com/inspect-js/node-deep-equal/commit/e02cadb650ef9d75684c015a35d2c59e029d5174) +- [Dev Deps] update `@ljharb/eslint-config`, `auto-changelog`, `aud`, `eslint`, `set-publish-latest`, `tape` [`11bd45b`](https://github.com/inspect-js/node-deep-equal/commit/11bd45b63943466c13a5ae97276796396a8f2619) +- [Tests] update `.github` from default branch [`58885d3`](https://github.com/inspect-js/node-deep-equal/commit/58885d3280fd25909ca5a17c7cec1e54bdd25233) +- [readme] update readme from default branch [`b0bca9a`](https://github.com/inspect-js/node-deep-equal/commit/b0bca9a1158a9596ec51a0404a6a8272b70ee204) +- [Tests] add `nyc` for coverage [`e25bc37`](https://github.com/inspect-js/node-deep-equal/commit/e25bc3716c7ec0390b06bd7b6fac0c9ab0968ab4) +- [Tests] use `Buffer.from` when available [`f0d4a42`](https://github.com/inspect-js/node-deep-equal/commit/f0d4a42fb87854e17d78cb2d6e9ec0156ea3d2f3) +- [Deps] update `is-arguments`, `is-date-object`, `is-regex`, `object-is`, `regexp.prototype.flags` [`80c15ca`](https://github.com/inspect-js/node-deep-equal/commit/80c15cae82164c888de8635287c3b44ab84b3fd4) +- [meta] use `npmignore` to autogenerate an npmignore file [`e0770e5`](https://github.com/inspect-js/node-deep-equal/commit/e0770e594ec683ded32fd1b14e876f087fc04f4a) +- [Deps] update `is-date-object`, `is-regex`, `object-is`, `regexp.prototype.flags` [`e4fb8c6`](https://github.com/inspect-js/node-deep-equal/commit/e4fb8c6459aa13d3a110b45e5612c31890a5d94e) +- [Tests] handle ported test failures in iojs v2 [`3798ff4`](https://github.com/inspect-js/node-deep-equal/commit/3798ff490286ee9ba70cf50c339914be355eea18) +- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `tape` [`0f8ca75`](https://github.com/inspect-js/node-deep-equal/commit/0f8ca7575e44c66fdf1dc2b6ad4e69e1b549369f) +- [Tests] handle some additional test differences in node <= 0.10 [`197a220`](https://github.com/inspect-js/node-deep-equal/commit/197a2203f0a95828c62ff2b3c980ddf16736913c) +- [meta] add missing `engines.node` [`e158993`](https://github.com/inspect-js/node-deep-equal/commit/e158993fcf913aca8a1ffdc037abfeeb3a5cb4e5) +- [meta] update `.gitignore` from default branch [`6ee186b`](https://github.com/inspect-js/node-deep-equal/commit/6ee186bd39199a1c05421e200b1e8e31a83cf363) +- [Dev Deps] update `tape` [`270d34b`](https://github.com/inspect-js/node-deep-equal/commit/270d34b48401ee40792bf18d06614044246776dd) +- [meta] fix URLs [`a269c18`](https://github.com/inspect-js/node-deep-equal/commit/a269c183bccb78dfdd2c88a149fe5373f13af4c0) +- [Tests] only use `Buffer.from` when it has a length of > 1 [`f7e5776`](https://github.com/inspect-js/node-deep-equal/commit/f7e577622d943da78c2c9cd1e070eb786cf7a68b) + ## [v1.1.1](https://github.com/inspect-js/node-deep-equal/compare/v1.1.0...v1.1.1) - 2019-11-12 ### Commits diff --git a/package.json b/package.json index ab66907..346f25b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "deep-equal", - "version": "1.1.1", + "version": "1.1.2", "description": "node's assert.deepEqual algorithm", "main": "index.js", "directories": {