File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -14,7 +14,13 @@ const messages = new Map();
1414const  {  defineProperty }  =  Object ; 
1515
1616// Lazily loaded 
17- var  util  =  null ; 
17+ var  util_  =  null ; 
18+ function  lazyUtil ( )  { 
19+   if  ( ! util_ )  { 
20+     util_  =  require ( 'util' ) ; 
21+   } 
22+   return  util_ ; 
23+ } 
1824
1925function  makeNodeError ( Base )  { 
2026  return  class  NodeError  extends  Base  { 
@@ -65,11 +71,11 @@ class AssertionError extends Error {
6571    if  ( message )  { 
6672      super ( message ) ; 
6773    }  else  { 
74+       const  util  =  lazyUtil ( ) ; 
6875      if  ( actual  &&  actual . stack  &&  actual  instanceof  Error ) 
6976        actual  =  `${ actual . name } ${ actual . message }  ; 
7077      if  ( expected  &&  expected . stack  &&  expected  instanceof  Error ) 
7178        expected  =  `${ expected . name } ${ expected . message }  ; 
72-       if  ( util  ===  null )  util  =  require ( 'util' ) ; 
7379      super ( `${ util . inspect ( actual ) . slice ( 0 ,  128 ) }   + 
7480        `${ operator } ${ util . inspect ( expected ) . slice ( 0 ,  128 ) }  ) ; 
7581    } 
@@ -104,7 +110,7 @@ function message(key, args) {
104110  if  ( typeof  msg  ===  'function' )  { 
105111    fmt  =  msg ; 
106112  }  else  { 
107-     if   ( util  ===    null )   util   =   require ( 'util' ) ; 
113+     const   util  =   lazyUtil ( ) ; 
108114    fmt  =  util . format ; 
109115    if  ( args  ===  undefined  ||  args . length  ===  0 ) 
110116      return  msg ; 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments