Small API.
Clear mental model.
Start with one method in a Worker. Add progress, cancellation and a pool as your application grows.
const worker = defineWorker(() => ({ fibonacci }));
const result = await math.fibonacci(40);Functions in the Worker.
Typed async calls everywhere else.
A guide for every layer.
Core concepts
Typed workers
How defineWorker and createWorker turn the functions of a worker into typed methods on the main thread.
Methods and the message
The three ways to write a worker method, what the message of a call offers, and the controls behind the methods.
Cancellation and progress
Report progress from a worker, cancel a call from either thread, and stop work that never pauses.
Transferable objects
Move large buffers between threads without copying them, in both directions.
Worker pools
Spread calls across several native Workers with one option, and control when they are created and released.
Guides
Creating workers
Every source createWorker accepts, and the setup for Vite, webpack, Parcel and files you serve yourself.
Runtime workers
Create a worker from a function, with no worker file, and learn the one rule that comes with it.
The message API
The original API of easy-web-worker - send, sendToMethod and onMessage - which typed methods are built on.
TypeScript
How the types of a worker are inferred, how to name them, and how to describe a worker you did not write with defineWorker.
Quality
See it run before you read.
Five live examples, each with its tested source.