MCPcopy Index your code
hub / github.com/nodejs/node / constructor

Method constructor

lib/vm.js:86–131  ·  view source on GitHub ↗
(code, options = kEmptyObject)

Source from the content-addressed store, hash-verified

84
85class Script extends ContextifyScript {
86 constructor(code, options = kEmptyObject) {
87 code = `${code}`;
88 if (typeof options === 'string') {
89 options = { filename: options };
90 } else {
91 validateObject(options, 'options');
92 }
93
94 const {
95 filename = 'evalmachine.<anonymous>',
96 lineOffset = 0,
97 columnOffset = 0,
98 cachedData,
99 produceCachedData = false,
100 importModuleDynamically,
101 [kParsingContext]: parsingContext,
102 } = options;
103
104 validateString(filename, 'options.filename');
105 validateInt32(lineOffset, 'options.lineOffset');
106 validateInt32(columnOffset, 'options.columnOffset');
107 if (cachedData !== undefined) {
108 validateBuffer(cachedData, 'options.cachedData');
109 }
110 validateBoolean(produceCachedData, 'options.produceCachedData');
111
112 const hostDefinedOptionId =
113 getHostDefinedOptionId(importModuleDynamically, filename);
114 // Calling `ReThrow()` on a native TryCatch does not generate a new
115 // abort-on-uncaught-exception check. A dummy try/catch in JS land
116 // protects against that.
117 try { // eslint-disable-line no-useless-catch
118 super(code,
119 filename,
120 lineOffset,
121 columnOffset,
122 cachedData,
123 produceCachedData,
124 parsingContext,
125 hostDefinedOptionId);
126 } catch (e) {
127 throw e; /* node-do-not-add-exception-line */
128 }
129
130 registerImportModuleDynamically(this, importModuleDynamically);
131 }
132
133 runInThisContext(options) {
134 const { breakOnSigint, args } = getRunInContextArgs(null, options);

Callers

nothing calls this directly

Calls 2

getHostDefinedOptionIdFunction · 0.85

Tested by

no test coverage detected