regexp-worker
v4.3.0
Published
Runs regular expressions on a background thread.
Maintainers
Readme
Regular Expression Worker
Execute Regular Expression Matches on a Node Worker Thread or in a Web Worker.
Regular Expressions can suffer from Catastrophic Backtracking. A very simple expression like /(x+x+)+y/ can cause your JavaScript application to freeze. This library allows you to run these expressions on another thread. If they take to long to complete, they are terminated, protecting your application from locking up.
Try it out: regexp-worker Playground
Installation
npm install regexp-workerBasic Usage
In the example below:
- a new Worker thread is created
- the regular expression is executed on the thread
- the result is returned
- the thread is stopped
For the occasional request, this is the easiest way, but the Worker startup and shutdown is expensive.
