| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent c3b9868 commit 11222f1
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -22,6 +22,7 @@ const primValues = { | |||
| 22 | 22 | 'empty_object': {}, | |
| 23 | 23 | 'regexp': /abc/i, | |
| 24 | 24 | 'date': new Date(), | |
| 25 | + 'invalidDate': new Date('foo'), | ||
| 25 | 26 | }; | |
| 26 | 27 | ||
| 27 | 28 | const primValues2 = { | |
@@ -34,6 +35,7 @@ const primValues2 = { | |||
| 34 | 35 | 'empty_object': {}, | |
| 35 | 36 | 'regexp': /abc/i, | |
| 36 | 37 | 'date': new Date(primValues.date), | |
| 38 | + 'invalidDate': new Date('foo'), | ||
| 37 | 39 | }; | |
| 38 | 40 | ||
| 39 | 41 | const primValuesUnequal = { | |
@@ -49,6 +51,7 @@ const primValuesUnequal = { | |||
| 49 | 51 | 'empty_object': [], | |
| 50 | 52 | 'regexp': /abc/g, | |
| 51 | 53 | 'date': new Date(primValues.date.getTime() + 1), | |
| 54 | + 'invalidDate': new Date(), | ||
| 52 | 55 | }; | |
| 53 | 56 | ||
| 54 | 57 | const bench = common.createBenchmark(main, { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -231,6 +231,9 @@ An alias of [`assert.ok()`][]. | |||
| 231 | 231 | <!-- YAML | |
| 232 | 232 | added: v0.1.21 | |
| 233 | 233 | changes: | |
| 234 | + - version: REPLACEME | ||
| 235 | + pr-url: https://github.com/nodejs/node/pull/57627 | ||
| 236 | + description: Invalid dates are now considered equal. | ||
| 234 | 237 | - version: v24.0.0 | |
| 235 | 238 | pr-url: https://github.com/nodejs/node/pull/57622 | |
| 236 | 239 | description: Recursion now stops when either side encounters a circular | |
@@ -422,6 +425,9 @@ parameter is an instance of {Error} then it will be thrown instead of the | |||
| 422 | 425 | <!-- YAML | |
| 423 | 426 | added: v1.2.0 | |
| 424 | 427 | changes: | |
| 428 | + - version: REPLACEME | ||
| 429 | + pr-url: https://github.com/nodejs/node/pull/57627 | ||
| 430 | + description: Invalid dates are now considered equal. | ||
| 425 | 431 | - version: v24.0.0 | |
| 426 | 432 | pr-url: https://github.com/nodejs/node/pull/57622 | |
| 427 | 433 | description: Recursion now stops when either side encounters a circular | |
@@ -2177,9 +2183,12 @@ added: | |||
| 2177 | 2183 | - v23.4.0 | |
| 2178 | 2184 | - v22.13.0 | |
| 2179 | 2185 | changes: | |
| 2180 | - - version: v24.0.0 | ||
| 2181 | - pr-url: https://github.com/nodejs/node/pull/57370 | ||
| 2182 | - description: partialDeepStrictEqual is now Stable. Previously, it had been Experimental. | ||
| 2186 | + - version: REPLACEME | ||
| 2187 | + pr-url: https://github.com/nodejs/node/pull/57627 | ||
| 2188 | + description: Invalid dates are now considered equal. | ||
| 2189 | + - version: v24.0.0 | ||
| 2190 | + pr-url: https://github.com/nodejs/node/pull/57370 | ||
| 2191 | + description: partialDeepStrictEqual is now Stable. Previously, it had been Experimental. | ||
| 2183 | 2192 | --> | |
| 2184 | 2193 | ||
| 2185 | 2194 | * `actual` {any} | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -299,10 +299,15 @@ function objectComparisonStart(val1, val2, mode, memos) { | |||
| 299 | 299 | } else if (val1Tag === '[object Object]') { | |
| 300 | 300 | return keyCheck(val1, val2, mode, memos, kNoIterator); | |
| 301 | 301 | } else if (isDate(val1)) { | |
| 302 | - if (!isDate(val2) || | ||
| 303 | - DatePrototypeGetTime(val1) !== DatePrototypeGetTime(val2)) { | ||
| 302 | + if (!isDate(val2)) { | ||
| 304 | 303 | return false; | |
| 305 | 304 | } | |
| 305 | + const time1 = DatePrototypeGetTime(val1); | ||
| 306 | + const time2 = DatePrototypeGetTime(val2); | ||
| 307 | + if (time1 !== time2) { | ||
| 308 | + // eslint-disable-next-line no-self-compare | ||
| 309 | + return time1 !== time1 && time2 !== time2; | ||
| 310 | + } | ||
| 306 | 311 | } else if (isRegExp(val1)) { | |
| 307 | 312 | if (!isRegExp(val2) || !areSimilarRegExps(val1, val2)) { | |
| 308 | 313 | return false; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -752,6 +752,8 @@ test('Additional tests', () => { | |||
| 752 | 752 | ||
| 753 | 753 | assertNotDeepOrStrict(new Date(), new Date(2000, 3, 14)); | |
| 754 | 754 | ||
| 755 | + assertDeepAndStrictEqual(new Date('foo'), new Date('bar')); | ||
| 756 | + | ||
| 755 | 757 | assertDeepAndStrictEqual(/a/, /a/); | |
| 756 | 758 | assertDeepAndStrictEqual(/a/g, /a/g); | |
| 757 | 759 | assertDeepAndStrictEqual(/a/i, /a/i); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments