@@ -385,22 +385,26 @@ const typesToCallDeepStrictEqualWith = [
385385 isKeyObject , isWeakSet , isWeakMap , Buffer . isBuffer , isSharedArrayBuffer ,
386386] ;
387387
388- function compareMaps ( actual , expected , comparedObjects ) {
389- if ( MapPrototypeGetSize ( actual ) !== MapPrototypeGetSize ( expected ) ) {
388+ function partiallyCompareMaps ( actual , expected , comparedObjects ) {
389+ if ( MapPrototypeGetSize ( expected ) > MapPrototypeGetSize ( actual ) ) {
390390 return false ;
391391 }
392- const safeIterator = FunctionPrototypeCall ( SafeMap . prototype [ SymbolIterator ] , actual ) ;
393392
394393 comparedObjects ??= new SafeWeakSet ( ) ;
394+ const expectedIterator = FunctionPrototypeCall ( SafeMap . prototype [ SymbolIterator ] , expected ) ;
395395
396- for ( const { 0 : key , 1 : val } of safeIterator ) {
397- if ( ! MapPrototypeHas ( expected , key ) ) {
396+ for ( const { 0 : key , 1 : expectedValue } of expectedIterator ) {
397+ if ( ! MapPrototypeHas ( actual , key ) ) {
398398 return false ;
399399 }
400- if ( ! compareBranch ( val , MapPrototypeGet ( expected , key ) , comparedObjects ) ) {
400+
401+ const actualValue = MapPrototypeGet ( actual , key ) ;
402+
403+ if ( ! compareBranch ( actualValue , expectedValue , comparedObjects ) ) {
401404 return false ;
402405 }
403406 }
407+
404408 return true ;
405409}
406410
@@ -553,7 +557,7 @@ function compareBranch(
553557) {
554558 // Check for Map object equality
555559 if ( isMap ( actual ) && isMap ( expected ) ) {
556- return compareMaps ( actual , expected , comparedObjects ) ;
560+ return partiallyCompareMaps ( actual , expected , comparedObjects ) ;
557561 }
558562
559563 if (
0 commit comments