summaryrefslogtreecommitdiff
path: root/lib/vm.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/vm.js')
-rw-r--r--lib/vm.js15
1 files changed, 9 insertions, 6 deletions
diff --git a/lib/vm.js b/lib/vm.js
index 1bb948fa55..6e735bca4a 100644
--- a/lib/vm.js
+++ b/lib/vm.js
@@ -32,7 +32,7 @@ const {
ERR_INVALID_ARG_TYPE,
ERR_VM_MODULE_NOT_MODULE,
} = require('internal/errors').codes;
-const { isModuleNamespaceObject, isUint8Array } = require('util').types;
+const { isModuleNamespaceObject, isArrayBufferView } = require('util').types;
const { validateInt32, validateUint32 } = require('internal/validators');
const kParsingContext = Symbol('script parsing context');
@@ -64,9 +64,12 @@ class Script extends ContextifyScript {
}
validateInt32(lineOffset, 'options.lineOffset');
validateInt32(columnOffset, 'options.columnOffset');
- if (cachedData !== undefined && !isUint8Array(cachedData)) {
- throw new ERR_INVALID_ARG_TYPE('options.cachedData',
- ['Buffer', 'Uint8Array'], cachedData);
+ if (cachedData !== undefined && !isArrayBufferView(cachedData)) {
+ throw new ERR_INVALID_ARG_TYPE(
+ 'options.cachedData',
+ ['Buffer', 'TypedArray', 'DataView'],
+ cachedData
+ );
}
if (typeof produceCachedData !== 'boolean') {
throw new ERR_INVALID_ARG_TYPE('options.produceCachedData', 'boolean',
@@ -346,10 +349,10 @@ function compileFunction(code, params, options = {}) {
}
validateUint32(columnOffset, 'options.columnOffset');
validateUint32(lineOffset, 'options.lineOffset');
- if (cachedData !== undefined && !isUint8Array(cachedData)) {
+ if (cachedData !== undefined && !isArrayBufferView(cachedData)) {
throw new ERR_INVALID_ARG_TYPE(
'options.cachedData',
- 'Uint8Array',
+ ['Buffer', 'TypedArray', 'DataView'],
cachedData
);
}