@@ -797,21 +797,18 @@ function createComparator (name, func) {
797797 if ( args . length === 2 ) {
798798 const a = runOptimizedOrFallback ( args [ 0 ] , engine , context , above )
799799 const b = runOptimizedOrFallback ( args [ 1 ] , engine , context , above )
800- if ( ! strict && typeof a !== typeof b ) {
801- if ( typeof a === 'string' && Number . isNaN ( + a ) ) throw NaN
802- if ( typeof b === 'string' && Number . isNaN ( + b ) ) throw NaN
803- return func ( + a , + b )
804- }
805- return func ( a , b )
800+ if ( strict || ( typeof a === 'string' && typeof b === 'string' ) ) return func ( a , b )
801+ if ( Number . isNaN ( + precoerceNumber ( a ) ) ) throw NaN
802+ if ( Number . isNaN ( + precoerceNumber ( b ) ) ) throw NaN
803+ return func ( + a , + b )
806804 }
807805 let prev = runOptimizedOrFallback ( args [ 0 ] , engine , context , above )
808806 for ( let i = 1 ; i < args . length ; i ++ ) {
809807 const current = runOptimizedOrFallback ( args [ i ] , engine , context , above )
810- if ( ! strict && typeof current !== typeof prev ) {
811- if ( typeof current === 'string' && Number . isNaN ( + current ) ) throw NaN
812- if ( i === 1 && typeof prev === 'string' && Number . isNaN ( + prev ) ) throw NaN
813- if ( ! func ( + prev , + current ) ) return false
814- } else if ( ! func ( prev , current ) ) return false
808+ if ( strict || ( typeof current === 'string' && typeof prev === 'string' ) ) if ( ! func ( prev , current ) ) return false
809+ if ( Number . isNaN ( + precoerceNumber ( current ) ) ) throw NaN
810+ if ( i === 1 && Number . isNaN ( + precoerceNumber ( prev ) ) ) throw NaN
811+ if ( ! func ( + prev , + current ) ) return false
815812 prev = current
816813 }
817814 return true
@@ -821,21 +818,18 @@ function createComparator (name, func) {
821818 if ( args . length === 2 ) {
822819 const a = await runOptimizedOrFallback ( args [ 0 ] , engine , context , above )
823820 const b = await runOptimizedOrFallback ( args [ 1 ] , engine , context , above )
824- if ( ! strict && typeof a !== typeof b ) {
825- if ( typeof a === 'string' && Number . isNaN ( + a ) ) throw NaN
826- if ( typeof b === 'string' && Number . isNaN ( + b ) ) throw NaN
827- return func ( + a , + b )
828- }
829- return func ( a , b )
821+ if ( strict || ( typeof a === 'string' && typeof b === 'string' ) ) return func ( a , b )
822+ if ( Number . isNaN ( + precoerceNumber ( a ) ) ) throw NaN
823+ if ( Number . isNaN ( + precoerceNumber ( b ) ) ) throw NaN
824+ return func ( + a , + b )
830825 }
831826 let prev = await runOptimizedOrFallback ( args [ 0 ] , engine , context , above )
832827 for ( let i = 1 ; i < args . length ; i ++ ) {
833828 const current = await runOptimizedOrFallback ( args [ i ] , engine , context , above )
834- if ( ! strict && typeof current !== typeof prev ) {
835- if ( typeof current === 'string' && Number . isNaN ( + current ) ) throw NaN
836- if ( i === 1 && typeof prev === 'string' && Number . isNaN ( + prev ) ) throw NaN
837- if ( ! func ( + prev , + current ) ) return false
838- } else if ( ! func ( prev , current ) ) return false
829+ if ( strict || ( typeof current === 'string' && typeof prev === 'string' ) ) if ( ! func ( prev , current ) ) return false
830+ if ( Number . isNaN ( + precoerceNumber ( current ) ) ) throw NaN
831+ if ( i === 1 && Number . isNaN ( + precoerceNumber ( prev ) ) ) throw NaN
832+ if ( ! func ( + prev , + current ) ) return false
839833 prev = current
840834 }
841835 return true
0 commit comments