vm: allow cachedData to also be TypedArray|DataView

PR-URL: https://github.com/nodejs/node/pull/22921
Refs: https://github.com/nodejs/node/issues/1826
Refs: https://github.com/nodejs/node/pull/22921#issuecomment-422350213
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Denys Otrishko <shishugi@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
This commit is contained in:
Benjamin Chen authored and Michaël Zasso committed 2018-11-02 20:34:43 +01:00
1 parent 84e5807b1e
commit 2331181410
5 files changed
+37 -29

No files matched your search

+5 -3
View File
@@ -178,18 +178,20 @@ const vm = require('vm');
'filename': 'string',
'columnOffset': 'number',
'lineOffset': 'number',
'cachedData': 'Uint8Array',
'cachedData': 'Buffer, TypedArray, or DataView',
'produceCachedData': 'boolean',
};
for (const option in optionTypes) {
const typeErrorMessage = `The "options.${option}" property must be ` +
`${option === 'cachedData' ? 'one of' : 'of'} type`;
common.expectsError(() => {
vm.compileFunction('', undefined, { [option]: null });
}, {
type: TypeError,
code: 'ERR_INVALID_ARG_TYPE',
message: `The "options.${option}" property must be of type ` +
`${optionTypes[option]}. Received type object`
message: typeErrorMessage +
` ${optionTypes[option]}. Received type object`
});
}