detect-webworker

1.0.0 • Public • Published

Install

npm install --save detect-webworker

Usage:

var isWebWorker = require('detect-webworker');
 
if (isWebWorker) {
  console.log("Running under Web Worker");
} else {
  console.log("Hello from not a Web Worker env");
}

The check is performed as:

module.exports = false;
try {
  module.exports = self instanceof WorkerGlobalScope
} catch(e) {}

Inspired from detect-node and idea taken from this stackoverflow issue

Readme

Keywords

Package Sidebar

Install

npm i detect-webworker

Weekly Downloads

7

Version

1.0.0

License

ISC

Last publish

Collaborators

  • borisirota