detect-webworker
v1.0.0
Published
Detect web worker environment
Downloads
22
Readme
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