I understand that JavaScript is a single-threaded language but I was wondering if there is any way to stop the execution of a long task if it`s taking too long.
I am working on a calculator and I use a lot of 3rd party libraries to perform calculations. Sometimes calculations can take too long and I want to be able to time-out, stop the calculation, and show an error or something.
So far I discovered that I can achieve this with WebWorkers but I don`t really like using them and they also introduce some overhead.
Is there any better way of achieving this?