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 ) {
2026return class NodeError extends Base {
@@ -65,11 +71,11 @@ class AssertionError extends Error{
6571if ( message ) {
6672super ( message ) ;
6773} else {
74+ const util = lazyUtil ( ) ;
6875if ( actual && actual . stack && actual instanceof Error )
6976actual = `${ actual . name } : ${ actual . message } ` ;
7077if ( expected && expected . stack && expected instanceof Error )
7178expected = `${ expected . name } : ${ expected . message } ` ;
72- if ( util === null ) util = require ( 'util' ) ;
7379super ( `${ util . inspect ( actual ) . slice ( 0 , 128 ) } ` +
7480`${ operator } ${ util . inspect ( expected ) . slice ( 0 , 128 ) } ` ) ;
7581}
@@ -104,7 +110,7 @@ function message(key, args){
104110if ( typeof msg === 'function' ) {
105111fmt = msg ;
106112} else {
107- if ( util === null ) util = require ( 'util' ) ;
113+ const util = lazyUtil ( ) ;
108114fmt = util . format ;
109115if ( args === undefined || args . length === 0 )
110116return msg ;
You can’t perform that action at this time.
0 commit comments