Creator here. Yes it's a wrapper around the Web Worker and Node Worker Threads API. In order to create an inline worker, the user provided function is serialized using .toString() and any provided yield statements (which specify outside variables, functions & imports) are extracted. Because JavaScript objects are passed by reference, we can get the references by running the user function on the main thread first (iterating over each yield statement), and stop on the last yield so the main thread doesn't execute the rest of the function. Then, whenever a thread mutates a shared variable, the new value is send or transfered to the main thread, which then updates the variable using the object's reference.
I do have a function that needs to run in a webworker, as it would block the UI for somewhere between 1s and 30s, but I can't see myself adopting this. It looks readable like normal JS. And so it hides its nature from the casual reader. The package does have the usual deadlock problems, so I totally expect this to cause problems.
ivanjermakov|2 years ago
W4G1|2 years ago
ksjskskskkk|2 years ago
and the world will suffer a multitude of common-for-users-but-edge-cases-for-the-devs triggering all sort of bugs for all of 2024.
mcvfijew|2 years ago
abdellah123|2 years ago
phantomathkg|2 years ago
tgv|2 years ago