detect-features
Version:
Detect and report browser and hardware features.
34 lines (27 loc) • 600 B
JavaScript
// @ts-check
/**
* Tests for inline web worker support
*
* @returns {boolean}
*/
export default (() => {
try {
// @ts-ignore
const URL = window.URL || window.webkitURL;
// @ts-ignore
if (URL === undefined || window.Blob === undefined || window.Worker === undefined) {
return false;
}
const blob = new Blob(['']);
const oURL = URL.createObjectURL(blob);
const worker = new Worker(oURL);
URL.revokeObjectURL(oURL);
if (worker) {
worker.terminate();
return true;
}
return false;
} catch (err) {
return false;
}
})();