
Making Web-Workers Async Iterables - jfet97
https://github.com/jfet97/aww
======
Waterluvian
I just started using web workers using the workerpool library last week.
There's something wildly satisfying about true parallelism in the browser.

I had an embarrassingly parallel problem with validating user drawn geometries
against hundreds of thousands of others in real time and web workers is a
godsend.

~~~
rl3
I'm assuming _workerpool_ doesn't support closures? Judging from its GitHub
page, it doesn't look like it.

From my own experience:

[https://news.ycombinator.com/item?id=20192486](https://news.ycombinator.com/item?id=20192486)

~~~
rezmason
Well, you could put Function.toString() in a Blob, like this, but it feels
kinda eval-y to me.

[http://jsfiddle.net/tndm5hev/](http://jsfiddle.net/tndm5hev/)

Edit: looks like someone wrote an NPM package already:

[https://www.npmjs.com/package/spawn-
worker](https://www.npmjs.com/package/spawn-worker)

~~~
ic4l
This is how Task.js functions

[https://github.com/icodeforlove/task.js](https://github.com/icodeforlove/task.js)

Which works on Node.js, and the browser. (Supports fork, worker_threads, and
WebWorkers)

The advantage of this is that the workers become generic enough to run
anything. Instead of having to have many "specialized" workers.

Performance-wise eval is not slow, and it is encapsulated inside of the actual
worker. Obviously you don't want a user to be able to control any input. But
for most cases we are talking about code related to processing, which involves
hard coded functions, and the "external-data" being ArrayBuffers.

