@@ -4,29 +4,24 @@ const ModuleJob = require('internal/modules/esm/module_job');
44const { SafeMap } = require ( 'internal/safe_globals' ) ;
55const debug = require ( 'util' ) . debuglog ( 'esm' ) ;
66const { ERR_INVALID_ARG_TYPE } = require ( 'internal/errors' ) . codes ;
7+ const { validateString } = require ( 'internal/validators' ) ;
78
89// Tracks the state of the loader-level module cache
910class ModuleMap extends SafeMap {
1011 get ( url ) {
11- if ( typeof url !== 'string' ) {
12- throw new ERR_INVALID_ARG_TYPE ( 'url' , 'string' , url ) ;
13- }
12+ validateString ( url , 'url' ) ;
1413 return super . get ( url ) ;
1514 }
1615 set ( url , job ) {
17- if ( typeof url !== 'string' ) {
18- throw new ERR_INVALID_ARG_TYPE ( 'url' , 'string' , url ) ;
19- }
16+ validateString ( url , 'url' ) ;
2017 if ( job instanceof ModuleJob !== true ) {
2118 throw new ERR_INVALID_ARG_TYPE ( 'job' , 'ModuleJob' , job ) ;
2219 }
2320 debug ( `Storing ${ url } in ModuleMap` ) ;
2421 return super . set ( url , job ) ;
2522 }
2623 has ( url ) {
27- if ( typeof url !== 'string' ) {
28- throw new ERR_INVALID_ARG_TYPE ( 'url' , 'string' , url ) ;
29- }
24+ validateString ( url , 'url' ) ;
3025 return super . has ( url ) ;
3126 }
3227}
0 commit comments