Skip to content

borisirota/detect-webworker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commits
 
 
 
 
 
 

Repository files navigation

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

About

Detect web worker environment

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published