Why This Library?

First, let's review the basic approach of using a Web Worker.

This approach is quite complex and requires careful handling of multiple concerns:

  • Preventing response collisions using message IDs
  • Proper error handling
  • Ensuring the correct function is invoked

However, this method does not handle:

  • Worker warm-up delays
  • Type safety for function calls
  • Timeouts for long-running tasks
  • Abort signals to cancel execution
  • Worker termination, where the promise might still be waiting for a response

This library was designed to eliminate these pain points while offering a more intuitive and streamlined approach to working with Web Workers.