@@ -45,6 +45,7 @@ const {
45
45
validateObject,
46
46
validateUint32,
47
47
validateString,
48
+ validateBuffer,
48
49
} = require ( 'internal/validators' ) ;
49
50
50
51
const binding = internalBinding ( 'module_wrap' ) ;
@@ -275,25 +276,16 @@ class SourceTextModule extends Module {
275
276
validateInt32 ( lineOffset , 'options.lineOffset' ) ;
276
277
validateInt32 ( columnOffset , 'options.columnOffset' ) ;
277
278
278
- if ( initializeImportMeta !== undefined &&
279
- typeof initializeImportMeta !== 'function' ) {
280
- throw new ERR_INVALID_ARG_TYPE (
281
- 'options.initializeImportMeta' , 'function' , initializeImportMeta ) ;
279
+ if ( initializeImportMeta !== undefined ) {
280
+ validateFunction ( initializeImportMeta , 'options.initializeImportMeta' ) ;
282
281
}
283
282
284
- if ( importModuleDynamically !== undefined &&
285
- typeof importModuleDynamically !== 'function' ) {
286
- throw new ERR_INVALID_ARG_TYPE (
287
- 'options.importModuleDynamically' , 'function' ,
288
- importModuleDynamically ) ;
283
+ if ( importModuleDynamically !== undefined ) {
284
+ validateFunction ( importModuleDynamically , 'options.importModuleDynamically' ) ;
289
285
}
290
286
291
- if ( cachedData !== undefined && ! isArrayBufferView ( cachedData ) ) {
292
- throw new ERR_INVALID_ARG_TYPE (
293
- 'options.cachedData' ,
294
- [ 'Buffer' , 'TypedArray' , 'DataView' ] ,
295
- cachedData
296
- ) ;
287
+ if ( cachedData !== undefined ) {
288
+ validateBuffer ( cachedData , 'options.cachedData' ) ;
297
289
}
298
290
299
291
super ( {
0 commit comments