Skip to content

Commit

Permalink
fix: detect web worker (#1711)
Browse files Browse the repository at this point in the history
  • Loading branch information
robertsLando committed Oct 10, 2023
1 parent df78893 commit a75a467
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ module.exports = {
commonjs: true,
es2021: true,
node: true,
worker: true,
},
extends: [
'airbnb-base',
Expand Down
4 changes: 3 additions & 1 deletion src/lib/is-browser.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
const isBrowser =
typeof window !== 'undefined' && typeof window.document !== 'undefined'
(typeof window !== 'undefined' && typeof window.document !== 'undefined') ||
// eslint-disable-next-line no-restricted-globals
(typeof self !== 'undefined' && typeof self.postMessage === 'function') // is web worker

export default isBrowser

0 comments on commit a75a467

Please sign in to comment.