@@ -12,7 +12,6 @@ const kCode = Symbol('code');
1212const messages = new Map ( ) ;
1313
1414// Lazily loaded
15- var assert = null ;
1615var util = null ;
1716
1817function makeNodeError ( Base ) {
@@ -55,9 +54,20 @@ class AssertionError extends Error {
5554 }
5655}
5756
57+ // This is defined here instead of using the assert module to avoid a
58+ // circular dependency. The effect is largely the same.
59+ function assert ( condition , message ) {
60+ if ( ! condition ) {
61+ throw new AssertionError ( {
62+ message,
63+ actual : false ,
64+ expected : true ,
65+ operator : '=='
66+ } ) ;
67+ }
68+ }
69+
5870function message ( key , args ) {
59- if ( assert === null ) assert = require ( 'assert' ) ;
60- assert . strictEqual ( typeof key , 'string' ) ;
6171 const msg = messages . get ( key ) ;
6272 assert ( msg , `An invalid error message key was used: ${ key } .` ) ;
6373 let fmt ;
@@ -188,7 +198,7 @@ E('ERR_INDEX_OUT_OF_RANGE', 'Index out of range');
188198E ( 'ERR_INVALID_ARG_TYPE' , invalidArgType ) ;
189199E ( 'ERR_INVALID_ARRAY_LENGTH' ,
190200 ( name , len , actual ) => {
191- assert . strictEqual ( typeof actual , 'number' ) ;
201+ assert ( typeof actual === 'number' , 'actual must be a number' ) ;
192202 return `The array "${ name } " (length ${ actual } ) must be of length ${ len } .` ;
193203 } ) ;
194204E ( 'ERR_INVALID_ASYNC_ID' , ( type , id ) => `Invalid ${ type } value: ${ id } ` ) ;
0 commit comments