* read request
* parse from JSON to an object
* read the data from the object in the worker to the main thread
* create a new object in the main thread with the data from the worker
Those last 2 steps are about as slow as a JSON.stringify and JSON.parse, and are completely unnecessary. As others have said, adding some filtering to the example makes this example worlds better.
Greenlet would execute the function in an entirely different thread, which isn't possible without the Web Worker API.
Someone please correct me if that's wrong!
That means that any I/O doens't block the main thread, and other parts of JS can execute.
This example provides literally no benefits, and actually is a performance hit from converting the data from JSON, then sending it back to the main thread (which itself copies the data in a method similar to converting back to JSON then back to an object again in the main thread).
(I had to do exactly that for a B2B app that was receiving hundreds of MB of data a while back)