How to create a child process from a string

Viewed 1057

In the browser, we can create workers from a javascript string as follows:

var blob = new Blob([sourceString]);
var url = window.URL.createObjectURL(blob);
var worker = new Worker(url);

Is there any way to do this with node's child process? I have a single JavaScript file I and want to create workers that are coded dynamically.

The source string is a created dynamically at run time.

The closest answer I found was this one, but it requires a seperate file.

2 Answers
Related