Runs a function in a separate thread by using a Web Worker, allowing long running functions to not block the UI.

Create a new Worker using a Blob object URL, the contents of which should be the stringified version of the supplied function.
Immediately post the return value of calling the function back.
Return a promise, listening for onmessage and onerror events and resolving the data posted back from the worker, or throwing an error.

继续阅读 30秒学会 JavaScript 片段 – runAsync