@@ -32,7 +32,7 @@ const {
3232 ERR_INVALID_ARG_TYPE ,
3333 ERR_VM_MODULE_NOT_MODULE ,
3434} = require ( 'internal/errors' ) . codes ;
35- const { isModuleNamespaceObject, isUint8Array } = require ( 'util' ) . types ;
35+ const { isModuleNamespaceObject, isArrayBufferView } = require ( 'util' ) . types ;
3636const { validateInt32, validateUint32 } = require ( 'internal/validators' ) ;
3737const kParsingContext = Symbol ( 'script parsing context' ) ;
3838
@@ -64,9 +64,12 @@ class Script extends ContextifyScript {
6464 }
6565 validateInt32 ( lineOffset , 'options.lineOffset' ) ;
6666 validateInt32 ( columnOffset , 'options.columnOffset' ) ;
67- if ( cachedData !== undefined && ! isUint8Array ( cachedData ) ) {
68- throw new ERR_INVALID_ARG_TYPE ( 'options.cachedData' ,
69- [ 'Buffer' , 'Uint8Array' ] , cachedData ) ;
67+ if ( cachedData !== undefined && ! isArrayBufferView ( cachedData ) ) {
68+ throw new ERR_INVALID_ARG_TYPE (
69+ 'options.cachedData' ,
70+ [ 'Buffer' , 'TypedArray' , 'DataView' ] ,
71+ cachedData
72+ ) ;
7073 }
7174 if ( typeof produceCachedData !== 'boolean' ) {
7275 throw new ERR_INVALID_ARG_TYPE ( 'options.produceCachedData' , 'boolean' ,
@@ -346,10 +349,10 @@ function compileFunction(code, params, options = {}) {
346349 }
347350 validateUint32 ( columnOffset , 'options.columnOffset' ) ;
348351 validateUint32 ( lineOffset , 'options.lineOffset' ) ;
349- if ( cachedData !== undefined && ! isUint8Array ( cachedData ) ) {
352+ if ( cachedData !== undefined && ! isArrayBufferView ( cachedData ) ) {
350353 throw new ERR_INVALID_ARG_TYPE (
351354 'options.cachedData' ,
352- 'Uint8Array' ,
355+ [ 'Buffer' , 'TypedArray' , 'DataView' ] ,
353356 cachedData
354357 ) ;
355358 }
0 commit comments