File tree Expand file tree Collapse file tree 1 file changed +15
-9
lines changed
Expand file tree Collapse file tree 1 file changed +15
-9
lines changed Original file line number Diff line number Diff line change 11/* global window self */
22
3- const isBrowser = typeof window !== 'undefined' && typeof window . document !== 'undefined' ;
3+ const isBrowser =
4+ typeof window !== "undefined" && typeof window . document !== "undefined" ;
45
56/* eslint-disable no-restricted-globals */
67const isWebWorker =
7- typeof self === ' object' &&
8+ typeof self === " object" &&
89 self . constructor &&
9- self . constructor . name === ' DedicatedWorkerGlobalScope' ;
10+ self . constructor . name === " DedicatedWorkerGlobalScope" ;
1011/* eslint-enable no-restricted-globals */
1112
1213const isNode =
13- typeof process !== ' undefined' &&
14+ typeof process !== " undefined" &&
1415 process . versions != null &&
1516 process . versions . node != null ;
1617
17- export {
18- isBrowser ,
19- isWebWorker ,
20- isNode
21- } ;
18+ /**
19+ * @see https://github.com/jsdom/jsdom/releases/tag/12.0.0
20+ * @see https://github.com/jsdom/jsdom/issues/1537
21+ */
22+ const isJsDom = ( ) =>
23+ ( typeof window !== "undefined" && window . name === "nodejs" ) ||
24+ navigator . userAgent . includes ( "Node.js" ) ||
25+ navigator . userAgent . includes ( "jsdom" ) ;
26+
27+ export { isBrowser , isWebWorker , isNode , isJsDom } ;
You can’t perform that action at this time.
0 commit comments