Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function importScripts() {
for (let i = 0; i < arguments.length; i++) {
const importScriptPath = arguments[i];
const importScriptSource = getScript(importScriptPath);
vm.runInThisContext(importScriptSource, global, {
filename: /^https?:/.test(importScriptPath) ? importScriptPath : 'data-url://',
});
}
}
global.importScripts = importScripts;
target.include = function(module) {
var code;
module = self.resolve(module, target);
if(null === module.match(/\.js$/)) {
module = module + ".js";
}
code = fs.readFileSync(module);
vm.runInThisContext(code, module);
};
function evalcx(code, context, filename) {
try {
return vm.runInThisContext(code, filename);
} catch (err) {
var regex = new RegExp('(at ' + filename + ':.*)[\\s\\S]*');
var syntaxRegex = /\s*at evalcx[\s\S]*/;
err.stack = err.stack.replace(syntaxRegex, '').replace(regex, '$1');
throw err;
}
};
var util = require("util");