@ -21,8 +21,7 @@
'use strict' ;
const { compare } = process . binding ( 'buffer' ) ;
const util = require ( 'util' ) ;
const { isSet , isMap } = process . binding ( 'util' ) ;
const { isSet , isMap , isDate , isRegExp } = process . binding ( 'util' ) ;
const { objectToString } = require ( 'internal/util' ) ;
const errors = require ( 'internal/errors' ) ;
@ -115,10 +114,9 @@ function areSimilarRegExps(a, b) {
}
// For small buffers it's faster to compare the buffer in a loop. The c++
// barrier including the Buffer.from operation takes the advantage of the faster
// compare otherwise. 300 was the number after which compare became faster .
// barrier including the Uint8Array operation takes the advantage of the faster
// binary compare otherwise. The break even point was at about 300 characters .
function areSimilarTypedArrays ( a , b ) {
const { from } = require ( 'buffer' ) . Buffer ;
const len = a . byteLength ;
if ( len !== b . byteLength ) {
return false ;
@ -131,8 +129,8 @@ function areSimilarTypedArrays(a, b) {
}
return true ;
}
return compare ( from ( a . buffer , a . byteOffset , len ) ,
from ( b . buffer , b . byteOffset , b . byteLength ) ) === 0 ;
return compare ( new Uint8Array ( a . buffer , a . byteOffset , len ) ,
new Uint8Array ( b . buffer , b . byteOffset , b . byteLength ) ) === 0 ;
}
function isFloatTypedArrayTag ( tag ) {
@ -186,11 +184,11 @@ function strictDeepEqual(actual, expected) {
// Skip testing the part below and continue in the callee function.
return ;
}
if ( util . isDate ( actual ) ) {
if ( isDate ( actual ) ) {
if ( actual . getTime ( ) !== expected . getTime ( ) ) {
return false ;
}
} else if ( util . isRegExp ( actual ) ) {
} else if ( isRegExp ( actual ) ) {
if ( ! areSimilarRegExps ( actual , expected ) ) {
return false ;
}
@ -219,10 +217,10 @@ function looseDeepEqual(actual, expected) {
if ( expected === null || typeof expected !== 'object' ) {
return false ;
}
if ( util . isDate ( actual ) && util . isDate ( expected ) ) {
if ( isDate ( actual ) && isDate ( expected ) ) {
return actual . getTime ( ) === expected . getTime ( ) ;
}
if ( util . isRegExp ( actual ) && util . isRegExp ( expected ) ) {
if ( isRegExp ( actual ) && isRegExp ( expected ) ) {
return areSimilarRegExps ( actual , expected ) ;
}
const actualTag = objectToString ( actual ) ;