File tree 1 file changed +15
-9
lines changed
1 file changed +15
-9
lines changed Original file line number Diff line number Diff line change 1
1
/* global window self */
2
2
3
- const isBrowser = typeof window !== 'undefined' && typeof window . document !== 'undefined' ;
3
+ const isBrowser =
4
+ typeof window !== "undefined" && typeof window . document !== "undefined" ;
4
5
5
6
/* eslint-disable no-restricted-globals */
6
7
const isWebWorker =
7
- typeof self === ' object' &&
8
+ typeof self === " object" &&
8
9
self . constructor &&
9
- self . constructor . name === ' DedicatedWorkerGlobalScope' ;
10
+ self . constructor . name === " DedicatedWorkerGlobalScope" ;
10
11
/* eslint-enable no-restricted-globals */
11
12
12
13
const isNode =
13
- typeof process !== ' undefined' &&
14
+ typeof process !== " undefined" &&
14
15
process . versions != null &&
15
16
process . versions . node != null ;
16
17
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