Skip to content

This module evaluates a string inside a Web Worker.

Notifications You must be signed in to change notification settings

leoancap/eval-worker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Eval Worker

This module evaluates a string in a Web Worker.

Example

const evalWorker = require("eval-worker")

evalWorker("2+3", 2000).then(result => {
  console.log(result) // 5
})
evalWorker("while(true){}", 2000).then(result => {
  console.log(result) // It is timed out after 2 seconds
})

Usage with Webpack

You will need to install worker-loader

// webpack.config.js
{
  module: {
    rules: [
      {
       test: /worker\.js$/,
       include: paths.appNodeModules, // path to your node_modules folder
       use: {
         loader: "worker-loader"
       }
      }
    ]
  }
}

About

This module evaluates a string inside a Web Worker.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published