Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
80529 views
1
/**
2
* Copyright 2013-2015, Facebook, Inc.
3
* All rights reserved.
4
*
5
* This source code is licensed under the BSD-style license found in the
6
* LICENSE file in the root directory of this source tree. An additional grant
7
* of patent rights can be found in the PATENTS file in the same directory.
8
*
9
* @providesModule ExecutionEnvironment
10
*/
11
12
/*jslint evil: true */
13
14
"use strict";
15
16
var canUseDOM = !!(
17
(typeof window !== 'undefined' &&
18
window.document && window.document.createElement)
19
);
20
21
/**
22
* Simple, lightweight module assisting with the detection and context of
23
* Worker. Helps avoid circular dependencies and allows code to reason about
24
* whether or not they are in a Worker, even if they never include the main
25
* `ReactWorker` dependency.
26
*/
27
var ExecutionEnvironment = {
28
29
canUseDOM: canUseDOM,
30
31
canUseWorkers: typeof Worker !== 'undefined',
32
33
canUseEventListeners:
34
canUseDOM && !!(window.addEventListener || window.attachEvent),
35
36
canUseViewport: canUseDOM && !!window.screen,
37
38
isInWorker: !canUseDOM // For now, this is true - might change in the future.
39
40
};
41
42
module.exports = ExecutionEnvironment;
43
44