1.0.0 • Published 9 years ago
detect-webworker v1.0.0
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
1.0.0
9 years ago