Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'use strict';
const path = require('path');
const Threads = require('threads');
const config = Threads.config;
const Spawn = Threads.spawn;
config.set({
basepath: {
node: path.join(__dirname, 'tasks')
}
});
class Thread {
constructor(task) {
this.task = task;
let options = undefined;
// Check if debug is an argument.
if (process.execArgv.reduce((prev, cur) => (prev || cur.indexOf('--debug') !== -1), false)) {
options = {execArgv: [`--debug=${Math.floor(Math.random() * (65535 - 1025)) + 1024}`]};