@@ -20,7 +20,7 @@ function areLinesEqual(actual, expected, checkCommaDisparity) {
2020 return false ;
2121}
2222
23- function myersDiff ( actual , expected , checkCommaDisparity = false ) {
23+ function myersDiff ( actual , expected , checkCommaDisparity = false , useNullPrototypes = true ) {
2424 const actualLength = actual . length ;
2525 const expectedLength = expected . length ;
2626 const max = actualLength + expectedLength ;
@@ -51,13 +51,13 @@ function myersDiff(actual, expected, checkCommaDisparity = false) {
5151 v [ offset ] = x ;
5252
5353 if ( x >= actualLength && y >= expectedLength ) {
54- return backtrack ( trace , actual , expected , checkCommaDisparity ) ;
54+ return backtrack ( trace , actual , expected , checkCommaDisparity , useNullPrototypes ) ;
5555 }
5656 }
5757 }
5858}
5959
60- function backtrack ( trace , actual , expected , checkCommaDisparity ) {
60+ function backtrack ( trace , actual , expected , checkCommaDisparity , useNullPrototypes ) {
6161 const actualLength = actual . length ;
6262 const expectedLength = expected . length ;
6363 const max = actualLength + expectedLength ;
@@ -87,16 +87,22 @@ function backtrack(trace, actual, expected, checkCommaDisparity) {
8787 while ( x > prevX && y > prevY ) {
8888 const actualItem = actual [ x - 1 ] ;
8989 const value = checkCommaDisparity && ! StringPrototypeEndsWith ( actualItem , ',' ) ? expected [ y - 1 ] : actualItem ;
90- ArrayPrototypePush ( result , { __proto__ : null , type : 'nop' , value } ) ;
90+ ArrayPrototypePush ( result , useNullPrototypes ?
91+ { __proto__ : null , type : 'nop' , value } :
92+ { type : 'nop' , value } ) ;
9193 x -- ;
9294 y -- ;
9395 }
9496
9597 if ( diffLevel > 0 ) {
9698 if ( x > prevX ) {
97- ArrayPrototypePush ( result , { __proto__ : null , type : 'insert' , value : actual [ -- x ] } ) ;
99+ ArrayPrototypePush ( result , useNullPrototypes ?
100+ { __proto__ : null , type : 'insert' , value : actual [ -- x ] } :
101+ { type : 'insert' , value : actual [ -- x ] } ) ;
98102 } else {
99- ArrayPrototypePush ( result , { __proto__ : null , type : 'delete' , value : expected [ -- y ] } ) ;
103+ ArrayPrototypePush ( result , useNullPrototypes ?
104+ { __proto__ : null , type : 'delete' , value : expected [ -- y ] } :
105+ { type : 'delete' , value : expected [ -- y ] } ) ;
100106 }
101107 }
102108 }
0 commit comments