🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more

eval-worker

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eval-worker

This module evaluates a string in a Web Worker.

1.0.8
latest
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created

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"
       }
      }
    ]
  }
}

FAQs

Package last updated on 04 Oct 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts