const { JSDOM } = require("jsdom");
const options = {
url: "http://example.com/",
};
const dom = new JSDOM(`
<!DOCTYPE html><html><head></head><body></div></body></html>
`, options);
var w = new dom.window.Worker("demo_workers.js");
var w = new dom.window.Worker("demo_workers.js");
^
TypeError: dom.window.Worker is not a constructor
at Object.<anonymous> (/Users/andrew/projects/swagger-linter/no-worker.js:10:9)
at Module._compile (module.js:624:30)
at Object.Module._extensions..js (module.js:635:10)
at Module.load (module.js:545:32)
at tryModuleLoad (module.js:508:12)
at Function.Module._load (module.js:500:3)
at Function.Module.runMain (module.js:665:10)
at startup (bootstrap_node.js:187:16)
at bootstrap_node.js:607:3
You'd probably get the error that the file doesn't exist but Worker
would be defined.
+1
Can people refrain from adding +1 comments? They are not helpful.
Fixing this will depend on Worker support in Node.js core, which is already supported by Ayo.js but yet to be backmerged into Node.js. Both the primary author of the feature and I are unfortunately short on time to make this happen soon.
People like @jcjolley might have overlooked (being so overwhelmed by trump election) this 2016 github feature: reactions.
Now that node supports the worker threads API should this be investigated again?
Most helpful comment
Now that node supports the worker threads API should this be investigated again?